n, k = gets.split(' ').map(&:to_i)
s = gets.slice(0, n)

lhp = 0
lup = 0
rhp = 0
rup = 0
s.each_char.with_index do |lr, i|
  if lr == 'L'
    if i != 0 && s[i-1] == 'L' then lhp += 1 elsif i != 0 then lup += 1 end
  else
    if s[i+1] == 'R' then rhp += 1 elsif s[i+1] != nil then rup += 1 end
  end
end

k.times do
  if lup >= 2
    lup -= 2
    lhp += 2
  elsif rup >= 2
    rup -= 2
    rhp += 2
  elsif lup == 1
    lup -= 1
    lhp += 1
  elsif rup == 1
    rup -= 1
    rhp += 1
  end
end
puts lhp + rhp