n,k=gets.split.map &:to_i
s=gets.chomp.chars
h=0
rl=0
lr=0
0.upto(n-2) do |i|
  h+=1 if s[i]==s[i+1]
  rl+=1 if s[i]=="R"&&s[i+1]=="L"
  lr+=1 if s[i]=="L"&&s[i+1]=="R"
end
puts h+((rl+1)/2+(lr+1)/2>k ? k*2:rl+lr)