N,K=list(map(int,input().split()))

S=eval(input())

h=0

for i in range(N-1):

  if i==0 and S[i]=="L":

    pass

  if S[i]==S[i+1]:

    h+=1

print((min(h+2*K,N-1)))
N,K=list(map(int,input().split()))

S=eval(input())

h=0

for i in range(N-1):

  if S[i]==S[i+1]:

    h+=1

print((min(h+2*K,N-1)))
N, K = list(map(int, input().split()))
S = eval(input())
h = 0
for i in range(N - 1):
    if i == 0 and S[i] == "L":
        pass
    if S[i] == S[i + 1]:
        h += 1
print((min(h + 2 * K, N - 1)))

N, K = list(map(int, input().split()))
S = eval(input())
h = 0
for i in range(N - 1):
    if S[i] == S[i + 1]:
        h += 1
print((min(h + 2 * K, N - 1)))

-    if i == 0 and S[i] == "L": -        pass