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