#include<iostream>
#include<string>
using namespace std;
int main(){
 string S;
 int N,K,out=0,count=0;
 cin>>N>>K>>S;
 int i=0,j=1;
 while(j<N){ 
  if(S[i]==S[j]){ 
      j++;
      out++;} 
  else 
  {i=j;
  j++;}}
 for(int t=K;t>0;t--) 
    out+=2;
    if(out>=N-1)
    out=N-1;
    cout<<out;
    return 0;
}