#include <bits/stdc++.h>
using namespace std;

int n,k,sum;
string s;

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