#include<iostream>
#include<string>

using namespace std;



int main()
{
    int N, K;
    string S;
    int i, j, k = 0;
	int happy = 0;
	cin>>N>>K>>S;
	i = 0;
	j = i + 1;
	while(j < N)
	{
		if(S[i] == S[j])
		{
			j++;
			happy++;
		}
		else
		{
			i = j;
			j++;
		}
	}
	for(k = K; k > 0; k--)
	{
		happy += 2;
	}
	if(happy >= N-1)
		happy = N-1;
	cout<<happy;
	return 0;
}

