#include<iostream>
#include<string>

using namespace std;


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