n,k=list(map(int,input().split()))

from itertools import*

print((n-max(len(list(groupby(eval(input()))))-k*2,1)))
n,k=list(map(int,input().split()))

s=eval(input())

c=s.count

print((n-1-max(c('LR')+c('RL')-k*2,0)))
n, k = list(map(int, input().split()))
from itertools import *

print((n - max(len(list(groupby(eval(input())))) - k * 2, 1)))

n, k = list(map(int, input().split()))
s = eval(input())
c = s.count
print((n - 1 - max(c("LR") + c("RL") - k * 2, 0)))

-from itertools import * - -print((n - max(len(list(groupby(eval(input())))) - k * 2, 1))) +s = eval(input()) +c = s.count +print((n - 1 - max(c("LR") + c("RL") - k * 2, 0)))