let count xs =
    let rec loop ls l un happy =
        match ls with
        | [_] -> (un, happy)
        | r::rs when l='L' & r='R' -> loop rs r (un+1) happy
        | r::rs when l=r -> loop rs r un (happy+1)
        | r::rs -> loop rs r un happy
    loop xs 'R' 0 0
let reads f = stdin.ReadLine().Split() |> Array.map f
let [| n; k; |] = reads int
let s = (stdin.ReadLine()).ToCharArray() |> Array.toList
let (unhappy, happy) = count s

printfn "%d" (min (2*k+happy) n)