#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin>>n;
string s;
cin>>s;//一开始我用for循环输出s发生了超时,其实可以直接输出
int current=0,maxlen=0;
for(int i=0;i<n;i++){
if(s[i]=='a'||s[i]=='h'){//分为两种情况:1.s[i]==a,h时。2.不为a,h
if(i==0||s[i-1]!='a'&&s[i-1]!='h'||s[i]==s[i-1]){
current=1;
}
else {current++;}}//当两个数不同时
else{
current=0;
}
maxlen=max(maxlen,current);
}
cout<<maxlen<<endl;
}



京公网安备 11010502036488号