import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto nk = readNums!int;
  auto s = readStr;
  int len = 1, ret;

  foreach(i; 0 .. nk[0]-1){
    if(s[i] == s[i+1]) ret++;
    else len++;
  }

  foreach(i; 0 .. nk[1]){
    if(len >= 3){
      len -= 2;
      ret += 2;
    } else if(len == 2){
      len -= 1;
      ret += 1;
    } else {
      break;
    }
  }

  writeln(ret);
}
