#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(void)
{
	int N,K,i,ans,cnt=0;

	string S;

	cin >> N >> K;

	cin >> S;

	for(i=0;i<N-1;i++)
		{
			if(S[i]==S[i+1])
				cnt++;

		}

	ans=min(N-1,cnt+2*K);

	cout << ans << endl;

		
}

