let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let (n, k) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n k -> (n, k)
let s = read_line ()
let s_len = String.length s

let rec f = function
  | ([], x :: xs) -> f ([[x]], xs)
  | (acc, []) -> acc
  | (("L" :: xs as acc) :: xss, "L" :: ys) -> f (("L" :: acc) :: xss, ys)
  | (("R" :: xs as acc) :: xss, "R" :: ys) -> f (("R" :: acc) :: xss, ys)
  | (xxs, y :: ys) -> f ([y] :: xxs, ys)
let ss = f ([], split_string s) |> List.map (String.concat "") |> List.rev

let rec g odd rest acc = function
  | [] -> acc
  | x :: xs ->
    if odd && rest > 0 then 
      let s = String.make (String.length x) (if x.[0] = 'L' then 'R' else 'L') in
      g (not odd) (rest - 1) (s :: acc) xs
    else g (not odd) rest (x :: acc) xs
let ss = g false k [] ss |> List.rev |> String.concat ""

let () =
  Array.init s_len (fun i ->
    if ss.[i] = 'L' then (if i <> 0 && ss.[i - 1] = 'L' then 1 else 0)
    else (if i < s_len - 1 && ss.[i + 1] = 'R' then 1 else 0)
  ) |> Array.fold_left (+) 0 |> Printf.printf "%d\n"