
#include<iostream>
using namespace std;
char line[10 ^ 5];
int add(char line[],int n,int k)
{
	int m = 0;
	int i,sum;
	for (i = 0; i < n-1; i++)
	{
		if (line[i] != line[i + 1])
			m++;
	}
	if (m == 1)
		sum = n - 1 - m + 2 * k - 1;
	else
		sum = n - 1 - m + 2 * k;
	return sum;
}
int main()
{
	int n,k;
	int i;
	int sum;
	cin >> n;
	cin >> k;
	for (i = 0; i < n; i++)
	{
		cin >> line[i];
	}
	sum = add(line, n, k);
	cout << sum;
	return 0;
}