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

lens = s.split('L').map(&:size) + s.split('R').map(&:size)
lens.keep_if{|it| it != 0}

base = lens.map{|it| it - 1}.inject(:+)
puts [n - 1, base + k * 2].min
