#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	int ans = 2 * k;
	for (int i = 1; i < n; ++i)
		if (s[i] == s[i - 1]) ans++;
	cout << min(ans, n - 1) << endl;

	return 0;
}