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

res = 0

lr = 0
rl = 0

s.length.times do |i|
  next if i >= s.length - 1
  res += 1 if s[i] == s[i + 1]
  lr += 1 if s[i] != s[i + 1] and s[i] == 'L'
  rl += 1 if s[i] != s[i + 1] and s[i] == 'R'
end

sw = [lr, rl, k].min

k -= sw
res += sw * 2
lr -= sw
rl -= sw

if lr+rl > 0 and k > 0
  res += 1
end

puts res