#include <cstdio>
#include <cstdlib>
#define MAXN 300010
using namespace std;
char os[MAXN];
int n,k,i,j;
int numb = 0;
int numa = 0;
int result;
int min = 300000;
int od;
int main(){
    freopen("muzej.in","r",stdin);
    freopen("muzej.out","w",stdout);
    int m = 1;
    scanf("%d %d",&n,&k);
    scanf("%s",os);
    j = n-1;
    while(j>=0 && m){
            if(os[j] == 'a') numa++;
            else numb ++;
            if(j<k){
                    if(((numa - numb) < min)&&(m == 1)&&((numa - numb) >= 0)){
                              min = numa - numb;
                              od = j;
                              if(min == 0){
                                     m = 0;                                                                                        }
                    }
            }
            j--;
    }
if(os[0] == 'b') result = 0;
else result = 1;
for(i=1 ;i < od; i++) {
          if(os[i] == 'a') result++;
          else if((os[i] == 'b') && (os[i-1] == 'b') && (os[i+1] == 'b')) result--;
          }
    printf("%d",result);
    return 0;
}
          
    
