let h = ref 0
let n, k, t = Scanf.scanf "%d %d %s" @@ fun n k s -> String.iteri (fun i c -> if i > 0 && s.[i - 1] = s.[i] then incr h) s; n, k, min k @@ (n - 1 - !h) / 2
let _ = Printf.printf "%d\n" @@ if k > t then n - 1 else !h + 2 * t