var n,m,i,r,a,b,ta,tb:longint;
    niz:array[0..300003] of char;
begin
  assign(input,'muzej.in');
  assign(output,'muzej.out');
  reset(input);
  rewrite(output);
  readln(n,m);
  for i:=1 to n do
   read(niz[i]);
  readln;
  for i:=1 to n do
   if niz[i]='a' then a:=a+1 else b:=b+1;
  for i:=1 to m-1 do
   begin
     if niz[i]='a' then ta:=ta+1
      else tb:=tb+1;
     if (ta>=tb) and (a-ta>=b-tb) then
      begin
        r:=r+1;
        a:=a-ta;
        b:=b-tb;
        ta:=0;
        tb:=0;
      end;
   end;
  writeln(r);
  close(input);
  close(output);
end.
