import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
//声明笑声的长度和内容
int n=in.nextInt();
String s= in.next();
int max=0;
int current=0;
//调取字符串里的单个字符 判断是否是除a、h以外其他的字符
for(int i=0;i<n;i++){
char m=s.charAt(i);
if(m!='a'&&m!='h'){
current=0;
continue;
}
if(i>0&&s.charAt(i)==s.charAt(i-1)){
current=1;
}
else{
current++;
}
if (current > max) {
max = current;
}
}
System.out.println(max);
}
}