#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <string>
#include <deque>

#pragma GCC optimize("O3")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef  double dbl;
typedef string str;



#define drobucs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//#define ff first
//#define ss second
#define pb push_back

const int  MOD = 1e9 + 7;
const int MAXN = 1e3 + 10;
const int INF = 2e9;
const ll INFL = 2e18;



int main() {
	drobucs;

	int n, k;
	str s, t = "i";
	cin >> n >> k >> s;
	int happy = 0;
	t += s;
	t += 't';
	for (int i = 1; i <= n; ++i) {
		if (t[i] == 'L') {
			if (t[i] == t[i + 1])happy++;
		}
		else {
			if (t[i] == t[i - 1])happy++;
		}
	}

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

	return 0;
}
