let count xs =
    let rec loop ys i =
        match ys with
        | [] | [_] -> i
        | h::hs when h <> hs.[0] -> loop hs (i+1)
        | h::hs -> loop hs i
    loop xs 0
let [| n; k; |] = reads int
let s = (stdin.ReadLine()).ToCharArray() |> Array.toList
n - 1 + (min 0 (2*k-(count s)))
|> printfn "%d"