#  LLLLRRRLLR  => LRLR
def run_length(s)
  ret = [s[0]]
  1.upto(s.size - 1) do |i|
    ret << s[i] if ret[-1] != s[i]
  end
  ret.join
end

def face_produces_unhappiness(n, s, k)
  n - [1, run_length(s).size - 2 * k].max
end

n, k = gets.split.map(&:to_i)
s = gets.chomp

puts face_produces_unhappiness(n, s, k)
