#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,c;
  cin >> a;
  cin >> c;
  string b;
  cin >> b;
  int x = 0;
  for(int i = 0;i < a-1;i++){
    if(b.at(i) == b.at(i+1))x++;
  }
  x = min(a-1,x+2*c);
  cout << x << endl;
}