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

inline bool is_happy(char cur,char lat)
{
	if (cur != '\0' && cur == lat)
		return true;
	else
		return false;
}

int main()
{
	int n, k, sum_happy = 0;
	cin >> n >> k;
	string str;
	char c;
	while (cin >> c)
		str.push_back(c);
	str.push_back('\0');
	for (int i = 0, j = 1; str[i] != '\0'; ++i, ++j)
		if (is_happy(str[i], str[j]))
			sum_happy++;
	cout << min(sum_happy + 2 * k, n - 1) << endl;
	return 0;
}