n,k = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("").map{|c| c == "L" ? -1 : 1}

k.times do
  index = -1
  tmp_arr = []
  lr = s[0]
  (0..s.length-1).each do |i|
    next if s[i] == lr
    index = i
    tmp_arr << s[i]
    (i+1..s.length-1).each do |j|
      if s[j] == lr then
        break
      else
        tmp_arr << s[j]
      end
    end
    break
  end
  break if index == -1
  length = tmp_arr.length
  tmp_arr.each_with_index do |c, i|
    s[index+length-1-i] = c * (-1)
  end
end

count = 0
s.each_cons(2) do |c1, c2|
  count += 1 if c1 == c2
end
puts count
