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

int n, k, ans;
string str;
int main() {
	cin >> n >> k;
	cin >> str;

	for (int i = 1; i < n; ++i)
		if (str[i] == str[i - 1])
			ans++;

	cout << min(n - 1, ans + 2 * k);

	return 0;
}