n, k  = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp
pre = s[0]
dif = 0
same = 0
1.upto(n-1) do |i|
  if pre == s[i]
    same += 1
  else
    dif += 1
  end
  pre = s[i]
end
if k*2 < dif
  same += k*2
else
  same += dif
end
puts same