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

t = 0
(0..n-1).each do |i|
  if s_1[i] == 'R'
    j = i
    while s_1[j] == 'R' do
      s_1[j] = 'L'
      j += 1
    end
    i = j
    t += 1
  end
  if t >= k
    break
  end
end

t = 0
(0..n-1).each do |i|
  if s_2[i] == 'L'
    j = i
    while s_2[j] == 'L' do
      s_2[j] = 'R'
      j += 1
    end
    i = j
    t += 1
  end
  if t >= k
    break
  end
end

ans1 = 0
(1..n-1).each do |i|
  if s_1[i] == s_1[i-1]
    ans1 += 1
  end
end

ans2 = 0
(1..n-1).each do |i|
  if s_2[i] == s_2[i-1]
    ans2 += 1
  end
end

puts [ans1, ans2].max