o,k = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.chars
#p k
#p s
hp = 0
s.inject do |i,j|
  if i == j
    hp += 1
  end
  j
end
#p hp
k.times do
  n = nil
  m = nil
  c = 0
  s.inject do |i,j|
    unless i == j
      if n.nil?
        n = c+1
      elsif m.nil?
        m = c
      else
        break
      end
    end
    c += 1
    j
  end
  t = []
  #p n
  #p m
  if !n.nil? and !m.nil?
    (n..m).each do |i|
      if s[i]=="R"
        t << "L"
      else
        t << "R"
      end
    end
    c = 0
    t.reverse_each do |i|
      s[n+c] = i
      c += 1
    end
    hp += 2
  elsif !n.nil?
    (n...o).each do |i|
      if s[i]=="R"
        s[i] = "L"
      else
        s[i] = "R"
      end
    end
    hp += 1
  end
  #p s
  #p hp
end
print("#{hp}")