#include<iostream>
#include<string>
#include<cmath>
using namespace std;


int main(){
	long i,N,K;
	string S;
	long count;
	cin>>N>>K>>S;
	for(i=0;i<N-1;i++)
		if(S[i]==S[i+1])
			count++;
	cout<<min(count+2*K,N-1);
}