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

count = 0
(n-1).times do |i|
  count += 1 if s[i] == s[i+1]
end

if (n - 1 - count) / 2 >= k
  count += 2 * k
else
  count += n - 1 - count
end

puts count