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

S = list(eval(input()))



flag = True

for i in range(1, N):

    if K != 0:

        if flag:

            if S[i-1] != S[i]:

                flag = False

        if not flag:

            S[i] = 'L' if S[i] == 'R' else 'R'

            if i < N - 1:

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

                    flag = True

                    K -= 1



ans = 0

if N > 1:

    if S[0] == 'R' and S[1] == 'R':

        ans += 1

    for i in range(1, N - 1):

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

            ans += 1

        elif S[i] == 'L' and S[i - 1] == 'L':

            ans += 1

    if S[-1] == 'L' and S[-2] == 'L':

        ans += 1



print(ans)

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

S = list(eval(input()))



flag = True

ans = 0

for i in range(1, N):

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

        ans += 1

    if K != 0:

        if flag:

            if S[i-1] != S[i]:

                flag = False

                ans += 1

        else:

            if S[i-1] != S[i]:

                flag = True

                ans += 1

                K -= 1

print(ans)
N, K = list(map(int, input().split()))
S = list(eval(input()))
flag = True
for i in range(1, N):
    if K != 0:
        if flag:
            if S[i - 1] != S[i]:
                flag = False
        if not flag:
            S[i] = "L" if S[i] == "R" else "R"
            if i < N - 1:
                if S[i] == S[i + 1]:
                    flag = True
                    K -= 1
ans = 0
if N > 1:
    if S[0] == "R" and S[1] == "R":
        ans += 1
    for i in range(1, N - 1):
        if S[i] == "R" and S[i + 1] == "R":
            ans += 1
        elif S[i] == "L" and S[i - 1] == "L":
            ans += 1
    if S[-1] == "L" and S[-2] == "L":
        ans += 1
print(ans)

N, K = list(map(int, input().split()))
S = list(eval(input()))
flag = True
ans = 0
for i in range(1, N):
    if S[i] == S[i - 1]:
        ans += 1
    if K != 0:
        if flag:
            if S[i - 1] != S[i]:
                flag = False
                ans += 1
        else:
            if S[i - 1] != S[i]:
                flag = True
                ans += 1
                K -= 1
print(ans)

+ans = 0 +    if S[i] == S[i - 1]: +        ans += 1 -        if not flag: -            S[i] = "L" if S[i] == "R" else "R" -            if i < N - 1: -                if S[i] == S[i + 1]: -                    flag = True -                    K -= 1 -ans = 0 -if N > 1: -    if S[0] == "R" and S[1] == "R": -        ans += 1 -    for i in range(1, N - 1): -        if S[i] == "R" and S[i + 1] == "R": -            ans += 1 -        elif S[i] == "L" and S[i - 1] == "L": -            ans += 1 -    if S[-1] == "L" and S[-2] == "L": -        ans += 1 +                ans += 1 +        else: +            if S[i - 1] != S[i]: +                flag = True +                ans += 1 +                K -= 1