n,k = map(int,input().split()); s=input()
l=0; r=0; b=0; t=k
res=0
while r<n :
if s[r] == 'b' : b+=1
if b<=t : res= max(res, r-l+1)
while b>t :
if s[l] == 'b' : b-=1
l+=1
r+=1
l=0; r=0; a=0; t=k
while r<n :
if s[r] == 'a' : a+=1
if a<=t : res= max(res, r-l+1)
while a>t :
if s[l] == 'a' : a-=1
l+=1
r+=1
print(res)
1296B - Food Buying | 133A - HQ9+ |
1650D - Twist the Permutation | 1209A - Paint the Numbers |
1234A - Equalize Prices Again | 1613A - Long Comparison |
1624B - Make AP | 660B - Seating On Bus |
405A - Gravity Flip | 499B - Lecture |
709A - Juicer | 1358C - Celex Update |
1466B - Last minute enhancements | 450B - Jzzhu and Sequences |
1582C - Grandma Capa Knits a Scarf | 492A - Vanya and Cubes |
217A - Ice Skating | 270A - Fancy Fence |
181A - Series of Crimes | 1638A - Reverse |
1654C - Alice and the Cake | 369A - Valera and Plates |
1626A - Equidistant Letters | 977D - Divide by three multiply by two |
1654B - Prefix Removals | 1654A - Maximum Cake Tastiness |
1649A - Game | 139A - Petr and Book |
1612A - Distance | 520A - Pangram |