#include <bits/stdc++.h>
int main(){
int n,k,t, tt = 0;
scanf("%d%d", &n, &k);
int res = k * 2;
for (int i = 0; i < n; i ++ ){
for (; (t = getchar()) < 33; );
if (t == tt) res ++ ;
tt = t;
}
if (res >= n) res = n - 1;
printf("%d", res);
}