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

S = eval(input())



happy = 0

ncc = 1 # number of connected components

for i in range(N):

    if S[i] == 'L':

        if i > 0 and S[i - 1] == 'L':

            happy += 1

    elif S[i] == 'R':

        if i < N - 1 and S[i + 1] == 'R':

            happy += 1

    if i > 0 and S[i] != S[i - 1]:

        ncc += 1

if ncc >= 3:

    p = min(K, (ncc - 1) // 2)

    ncc -= 2 * p

    happy += 2 * p

    K -= p

if ncc == 2 and K > 0:

    happy += 1

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

S = eval(input())



happy = 0

ncc = 1 # number of connected components

for i in range(N - 1):

    ncc += S[i] != S[i + 1]

if ncc >= 3:

    p = min(K, (ncc - 1) // 2)

    ncc -= 2 * p

    K -= p

if ncc == 2 and K > 0:

    ncc -= 1

print((N - ncc))
N, K = list(map(int, input().split()))
S = eval(input())
happy = 0
ncc = 1  # number of connected components
for i in range(N):
    if S[i] == "L":
        if i > 0 and S[i - 1] == "L":
            happy += 1
    elif S[i] == "R":
        if i < N - 1 and S[i + 1] == "R":
            happy += 1
    if i > 0 and S[i] != S[i - 1]:
        ncc += 1
if ncc >= 3:
    p = min(K, (ncc - 1) // 2)
    ncc -= 2 * p
    happy += 2 * p
    K -= p
if ncc == 2 and K > 0:
    happy += 1
print(happy)

N, K = list(map(int, input().split()))
S = eval(input())
happy = 0
ncc = 1  # number of connected components
for i in range(N - 1):
    ncc += S[i] != S[i + 1]
if ncc >= 3:
    p = min(K, (ncc - 1) // 2)
    ncc -= 2 * p
    K -= p
if ncc == 2 and K > 0:
    ncc -= 1
print((N - ncc))

-for i in range(N): -    if S[i] == "L": -        if i > 0 and S[i - 1] == "L": -            happy += 1 -    elif S[i] == "R": -        if i < N - 1 and S[i + 1] == "R": -            happy += 1 -    if i > 0 and S[i] != S[i - 1]: -        ncc += 1 +for i in range(N - 1): +    ncc += S[i] != S[i + 1] -    happy += 2 * p -    happy += 1 -print(happy) +    ncc -= 1 +print((N - ncc))