N, K = gets.split.map!(&:to_i)
S = gets.chomp!.codepoints

L = 76
R = 82

SW = case [S[0], S[N-1]]
       when [L, R] then [R, L]
       when [L, L] then [R, L]
       when [R, L] then [L, R]
       when [R, R] then [L, R]
     end

ans = 0
0.upto(N-2) do |i|
  ans += 1 if S[i] == S[i+1]
end

k = K
1.upto(N-2) do |i|
  break if k <= 0

  if S[i] == SW[0] && S[i+1] == SW[1]
    ans += 2
    k -= 1
  end
end

if k > 0 && S[0] == SW[0]
  ans += 1
  k -= 1
end

if k > 0 && S[N-1] == SW[0]
  ans += 1
  k -= 1
end

puts ans
