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

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