open System

let [| N; K |] = stdin.ReadLine().Split() |> Array.map int
let S = stdin.ReadLine().ToCharArray()

let mutable idx = 0
let mutable j = 0

let mutable c =
    if S.[0] = 'R' then 'L'
    else 'R'

for i in [ 0..(K - 1) ] do
    idx <- Array.IndexOf(S, c, j)
    if idx = -1 then ()
    else
        j <- idx
        while j < S.Length && S.[j] <> S.[0] do
            S.[j] <- S.[0]
            j <- j + 1

let mutable result = 0

for i in [ 1..(N - 1) ] do
    if S.[i - 1] = S.[i] then result <- result + 1

result |> stdout.WriteLine
