# frozen_string_literal: true

line = gets.chomp!.split(' ')

n = line[0].to_i

k = line[1].to_i

s = gets

happiness = 0

s.length.times do |i|
  happiness += 1 if %w[LL RR].include?(s[i, 2])
end

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