#include <iostream>
using namespace std;
int find(int*a, int n, int k){
    int c=count(a,n);
    int temp=0;
    int p=1;
    int q=n-1;
    while(temp<k){
        while(a[p] == a[p-1]){
            p=p+1;
        }
        while(a[q]==a[q+1]){
            q=q-1;
        }
        if(p<=q){
            for(int i=p;i<=q;i++){
                a[i]=-a[i];
            }
            c+=2;
        }
        else{
            for(int i=0;i<=q;i++){
                a[i]=-a[i];
            }
            c+=1;
        }
        temp++;
    }
    return c;
}
int main(){
    int n = 0, k = 0;
    cin>>n>>k;
    char s[n];
    cin>>s;
    int a[n];
    for (int i=0;i<n;i++){
      a[i]=(s[i]=='L'?1:-1);
    }
    int res=find(a,n,k);
    cout<<res;
}