str = gets.split
N,K = str[0].to_i, str[1].to_i
S = gets.chomp
c = 0
answer = 0

for i in 0...N-1 do
    if S[i] == S[i+1]
        answer += 1
    else
        c += 1
    end
end

answer += 2*K
if answer >= N
    answer = N-1
end

puts answer