n,k = gets.split.map(&:to_i)
face = gets.chomp.split("")
happy = 0
count = 0
for i in 1..n-1
  if face[i] == face[i-1]
    happy += 1
  else face[i] == "L" && face[i-1] == "R"
    count += 1
  end
end
if k*2 < count
  happy += k*2
else
  happy += count
end

puts happy
