#include <cstdio>
#include <algorithm>

using namespace std;

int n,m,a;
int i,l,num,cnt;
char val[300030];

int main()
{
    freopen("muzej.in","r",stdin);
    freopen("muzej.out","w",stdout);
    scanf("%d%d",&n,&m);
    scanf("%s",val+1);
    for (a=1; a<=n; a++) if (val[a]=='a') i++; else i--;
    l=1;
    while (l<m)
    {
        if (val[l]=='a') num++; else num--;
        if (num==0) cnt++;
        if (num==1 && i>0)
        {
            i--;
            num=0;
            cnt++;
        }
        l++;
    }
    printf("%d",cnt);
}
