from itertools import groupby



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

print((n - max(1, sum(map(bool, groupby(eval(input())))) - 2 * k)))

from itertools import groupby



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

print((n - max(1, sum(1 for _ in groupby(eval(input()))) - 2 * k)))

from itertools import groupby

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

from itertools import groupby

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

-print((n - max(1, sum(map(bool, groupby(eval(input())))) - 2 * k))) +print((n - max(1, sum(1 for _ in groupby(eval(input()))) - 2 * k)))