#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName
#define INPUT_LLINT(valName) long long int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string& str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }

template <long long int MOD> long long int mod_inv(long long int a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}

template <long long int MOD> long long int mod_add(long long int a, long long int b) {
	return (a + b) % MOD;
}

template <long long int MOD> long long int mod_sum(long long int a, long long int b) {
	return (a - b) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b) {
	return (a % MOD) * (b % MOD) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b, long long int c) {
	return mod_mul<MOD>(a, mod_mul<MOD>(b, c));
}

template <long long int MOD> long long int mod_div(long long int a, long long int b) {
	return (a % MOD) * mod_inv<MOD>(b) % MOD;
}


//------------------------------------------------------------------------------------------------------------------------------

void rotate(string& s, int l, int r) {
	for (int i = 0; l+i <= r-i; ++i) {
		swap(s[l+i], s[r-i]);
		s[l + i] = s[l + i] == 'L' ? 'R' : 'L';
		s[r - i] = s[r - i] == 'L' ? 'R' : 'L';
	}
}

long long int count(string& s) {
	long long int n = 0;
	for (int i = 0; i < s.length(); ++i) {
		if (   s[i] == 'L' && i > 0 && s[i-1] == 'L'
			|| s[i] == 'R' && i < s.length()-1 && s[i + 1] == 'R'
			) {
			++n;
		}
	}
	return n;
}

int main() {
	
	// TODO: streamやめる

	cin.tie(0); ios::sync_with_stdio(false);

	INPUT_LLINT(N);
	INPUT_LLINT(K);
	INPUT_STR(S);

	long long int n = count(S);

	long long int a = 0;

	int LR = 0;
	int RL = 0;
	REP(i, N-1) {
		if (S[i] == 'L' && S[i + 1] == 'R') ++LR;
		if (S[i] == 'R' && S[i + 1] == 'L') ++RL;
	}

	a = min(LR, RL);
	
	a = min(a, K);

	n += a * 2;

	LR -= a;
	RL -= a;

	K -= a;
	if (K > 0) {

		if (S[0] == 'L' && LR > 0) {
			LR -= 1;
			n += 1;
			K -= 1;
		} else if (S[0] == 'R' && RL > 0) {
			RL -= 1;
			n += 1;
			K -= 1;
		}
	}
	if(K>0){
		if (S[N-1] == 'R' && LR > 0) {
			LR -= 1;
			n += 1;
			K -= 1;
		} else if (S[N-1] == 'L' && RL > 0) {
			RL -= 1;
			n += 1;
			K -= 1;
		}

	}

	OUTPUT(n);

	return 0;
}

Measured memory_bytes: 512