local function str2tbl(s)
    local sub = string.sub
    local t = {}
    for i=1, #s do
        t[i] = sub(s, i, i)
    end
    return t
end

local N, K = io.read("n", "n", "l")
local S = str2tbl(io.read("l"))
local h = 0
local sw = 0
for i=1,N-1 do
    if S[i] == 'L' and S[i+1] == 'L' then
        h = h + 1
    elseif S[i] == 'R' and S[i+1] == 'R' then
        h = h + 1
    else
        sw = sw + 1
    end
end
for k=1,K do
    if sw == 0 then
        break
    elseif sw == 1 then
        h = h + 1
        break
    else
        h = h + 2
        sw = sw - 2
    end
end
print(h)