def min(a,b); a < b ? a : b; end
def max(a,b); a > b ? a : b; end
  
N, K = gets.split.map(&:to_i)
S = "R#{gets.chomp}L"

x = 0
y = 0

(0 .. N).each do |i| 
  if S[i,2] == 'RL' 
    if i == 0 || i == N
      y += 1
    else
      x += 1
    end
  end
end

puts N - 2 * max(x - K, 0) - max(y - max(K - x, 0), 0)



