#include<iostream>
using namespace std;
#define df 0

int main(){
  int n,k; cin >>n >>k;
  char p; cin >>p;
  int cnt=0;
  for(int i=1;i<n;i++){
    char c; cin >>c;
    if(c==p)cnt++;
    p=c;
  }
  cout << min(cnt+2*k,n-1);
}

/// confirm df==0 ///
