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

#s.chunk(&:itself).each {|key, arr|
#  puts "#{key}: #{arr.inspect}"
#  #puts "#{key}: #{arr.to_s}"
#}

happy = n - s.chunk(&:itself).count
happy += k*2  # +2 happy / 1 switch

puts [n-1, happy].min