#include <bits/stdc++.h>

using namespace std;


int main() {
    int N,K; cin >> N >> K;
    string S; cin >> S;
    int count = 0;
    for(int i=1;i<N;i++) {
        if(S[i-1] == S[i]) count++;
    }
    cout << min(count + 2*K, N-1) << endl;
    return 0;
}
