N,K=list(map(int,input().split()));S=eval(input());u=[S[0]]

for c in S:c==u[-1]or u.append(c)

print((len(S)-max(len(u)-2*K,1)))
n,s=open(0);n,k=list(map(int,n.split()));print((n-max(sum(i!=j for i,j in zip(s,s[1:]))-2*k,1)))
N, K = list(map(int, input().split()))
S = eval(input())
u = [S[0]]
for c in S:
    c == u[-1] or u.append(c)
print((len(S) - max(len(u) - 2 * K, 1)))

n, s = open(0)
n, k = list(map(int, n.split()))
print((n - max(sum(i != j for i, j in zip(s, s[1:])) - 2 * k, 1)))

-N, K = list(map(int, input().split())) -S = eval(input()) -u = [S[0]] -for c in S: -    c == u[-1] or u.append(c) -print((len(S) - max(len(u) - 2 * K, 1))) +n, s = open(0) +n, k = list(map(int, n.split())) +print((n - max(sum(i != j for i, j in zip(s, s[1:])) - 2 * k, 1)))