integer N,K
character(10**5) S
integer x,y
integer ans
read*,N,K
read*,S

x=0;y=0
if (s(1:1) =="L")y=y+1
if (s(N:N) =="R")y=y+1
do i=1,N-1
  if( s(i:i)=="R" .and. s(i+1:i+1) == "L")x=x+1
end do

if(K<X)then
  ans = n - (2*(x-k) + y)
else if(X==K.and.Y==2)then
  ans = n - 2
else
  ans = n - 1
endif 

print"(i0)",ans
end