class Array
  def score_abc140
    n = size
    self << 0
    res = 0
    n.times{|i| res += 1 if self[i+1] == self[i] }
    res
  end
end

n, k = gets.to_s.split.map{|t| t.to_i }
s = gets.chomp.bytes

puts [ s.score_abc140 + 2 * k, n - 1].min 