# Codeforces Round #354 (Div. 2) C. Vasya and String 尺取

#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;

char s[maxn];
int a[maxn];
int n,k;

int work(){
int s=0,t=0,ans=0;
int cnt=0;
while( s<=t ){
while( cnt<=k &&t<n ){
if( a[t]==0 ){
cnt++;
}
if(cnt<=k)
ans=max( ans,t-s+1 );
t++;
}
if( a[s]==0 )cnt--;
s++;
}
return ans;
}

int main()
{
scanf("%d%d",&n,&k);
scanf("%s",s);
for(int i=0;i<n;i++){
a[i]=s[i]-'a';
}
int ans1=work();
for(int i=0;i<n;i++)a[i]=a[i]?0:1;
int ans2=work();
printf("%d\n",max(ans1,ans2));

return 0;
}


#### Codeforces Round #448 (Div. 2) ABC

2017-11-27 14:47:02

#### C. DNA Alignment(Codeforces Round #295(div2))

2015-03-02 18:27:17

#### Codeforces Round #444 (Div. 2)-贪心&尺取-Ratings and Reality Shows

2017-11-11 20:11:11

#### Codeforces Round #471 div.2 ABC题解

2018-03-24 14:16:58

#### Codeforces Round #482 (Div. 2)

2018-05-15 12:51:24

#### Codeforces Round #495 (Div. 2) C. Sonya and Robots（模拟）

2018-07-07 15:36:24

#### Codeforces Round #480 (Div. 2): C. Posterized（贪心）

2018-05-09 17:11:24

#### Tinkoff Internship Warmup Round 2018 and Codeforces Round #475 (Div. 2) C. Alternating Sum

2018-04-18 11:14:58

#### Educational Codeforces Round 38 (Rated for Div. 2) B. Run For Your Prize

2018-02-17 13:35:37

#### Codeforces Round #459 (Div. 2)The Monster[匹配问题]

2018-01-30 15:20:19