#include
#include
#include
using namespace std;
void perfectness(char arr[], int k){
int fre[2]={0};
int maxfre = 0,maxlen=0, Start = 0, End = 0;
//char perfChar;
while(End<strlen(arr)){
if(arr[End]==βaβ){
fre[0]++;
}else if(arr[End]==βbβ){
fre[1]++;
}
maxlen=max(maxlen,End-Start+1);
maxfre=max(maxfre,fre[arr[End]-βaβ]);
if(End-Start+1-maxfre>k){
fre[arr[End]-βaβ]β;
Start++;
}
End++;
}
cout<<maxlen;
}
int main(){
int k;
cin >> k;
char arr[1000];
cin >> arr;
perfectness(arr,k);
return 0;
}