import scala.io.StdIn
object Main extends App {
  val List(n,k) = StdIn.readLine().split(" ").map(_.toInt).toList
  val S = StdIn.readLine()
  val initialScore = (for (i <- 0 until n-1) yield if (S(i) == S(i+1)) 1 else 0).sum
  println((n-1).min(initialScore + 2 * k))
}
