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

def devide_str(_s)
  pre = str = _s[0]
  part = []
  (1..(_s.length - 1)).each do |i|
    if _s[i] != pre
      part.push(str)
      pre = str = _s[i]
    else
      str += _s[i]
    end
  end
  part.push(str)
end

ansstr = s
k.times do |i|
  parts = devide_str(ansstr)
  if parts.length > 1
    if parts[1].split('')[0] == 'R'
      parts[1].gsub!(/R/, 'L')
    else
      parts[1].gsub!(/L/, 'R')
    end
  end
  ansstr = parts.join('')
end

ansary = ansstr.split('')
ans = 0
pre = ansary[0]

(1..(ansary.length - 1)).each do |e|
  if pre == ansary[e]
    ans += 1
  else
    pre = ansary[e]
  end
end

puts ans.to_s
