#include <stdio.h>
#include <string.h>
int main()
{FILE *in,*out;
 in=fopen("muzej.in","r");
 out=fopen("muzej.out","w");
 long n,m,i,a=0,b=0,hold=0,arez=0,brez=0;
 char c[300000];
fscanf(in,"%ld%ld",&n,&m);
fscanf(in,"%s",&c);m--;
i=m;
while (i>=0)
{
  while(i>=0 && c[i]=='b')
  {b++;
   i--;
   }
   b+=brez;
   if (arez){if (arez>b){arez-=b;b=0;}
            else {b-=arez;arez=0;}
            hold++;
            }
   brez=b;b=0;
   while(i>=0 && c[i]=='a')
   {a++;
    i--;
    }
    a+=arez;
    if (brez) {if (brez>a){brez-=a;a=0;}
                else{a-=brez;brez=0;}
                hold++;
                } 
   arez=a;a=0;
} 
hold+=arez;
fprintf(out,"%ld",hold-1); 
   fclose(in);
   fclose(out);
}               
