nn, kk = gets.split.map(&:to_i)
ss = gets.chomp

if nn==1
  puts 0
  exit
end

# いれかえ
kk.times do |k|
  # 端なし
  reg = "LR.*RL|RL.*LR|LRL|RLR"
  idx = ss.index(/#{reg}/)
  if idx.nil?
    # 端を考慮
    reg = "(?:L|^)R.*R(?:L|$)|(?:R|^)L.*L(?:R|$)"
    idx = ss.index(/#{reg}/)
    break if idx.nil?
  end
  str = ss.scan(/#{reg}/).first
  # 切る位置調整 #TODO 正規表現でうまくできたらこれ不要
  if str[0]!=str[1]
    str=str[1..-1]
    idx+=1
  end
  if str[-1]!=str[-2]
    str=str[0..-2]
  end

  rotate = ss[idx..(idx +(str.length-1))].reverse.gsub("R","Z").gsub("L","R").gsub("Z","L")
  if idx==0
    ss = rotate + ss[(idx+str.length)..-1]
  else
    ss = ss[0..idx-1] + rotate + ss[(idx+str.length)..-1]
  end
end
#puts ss#d

# カウント
sum = 0
prev = 'R'
0.upto(nn-2) do |n|
  if ss[n]=='R' && ss[n+1]=='R'
    sum+=1
  elsif ss[n]=='L' && prev=='L'
    sum+=1
  end
  prev = ss[n]
end
# 最後
if ss[-1]=='L' && ss[-2]=='L'
  sum+=1
end

puts sum
