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

#$stderr.puts "'#{s}'"

h = 0
(1...n).each do |i|
#  $stderr.puts "#{i-1}:#{s[i-1]} - #{i}:#{s[i]}"
  if s[i-1] == s[i]
    h += 1
  end
end


#$stderr.puts h
h += 2 * k
#$stderr.puts h

unless h < n
  h = n - 1
end
puts h
