n,k = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("").map{|c| c == "L" ? -1 : 1}

score = 0
s.each_cons(2) do |c1, c2|
  if c1 == c2 then
    score += 1
  end
end

puts [score + 2 * k, n - 1].min
