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

S = eval(input())



x = S.count("RL")

y = int(S[0] == "L") + int(S[-1] == "R")

    

print((min(N - 1, N - (x * 2 + y) + K * 2)))

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

S = eval(input())



x = S.count("RL")

y = int(S[0] == "L") + int(S[-1] == "R")

print((min(N - 1, N - 2 * x - y + 2 * K)))

N, K = list(map(int, input().split()))
S = eval(input())
x = S.count("RL")
y = int(S[0] == "L") + int(S[-1] == "R")
print((min(N - 1, N - (x * 2 + y) + K * 2)))

N, K = list(map(int, input().split()))
S = eval(input())
x = S.count("RL")
y = int(S[0] == "L") + int(S[-1] == "R")
print((min(N - 1, N - 2 * x - y + 2 * K)))

-print((min(N - 1, N - (x * 2 + y) + K * 2))) +print((min(N - 1, N - 2 * x - y + 2 * K)))