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

int main() {
	int n,k;cin>>n>>k;
	string s;cin>>s;
	int ans=0;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]==s[i+1])ans++;
	}
	cout<<min(ans+2*k,n-1)<<endl;
	return 0;
}
