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

A = list(map(int, input().split()))

B = {i:0 for i in set(A)}

for a in A:

    B[a] += 1

print((sum(sorted(B.values())[:-K])))
N, K = list(map(int, input().split()))

B = {}

for i in input().split():

    if i in B:

        B[i] += 1

    else:

        B[i] = 1

print((sum(sorted(B.values())[:-K])))
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = {i: 0 for i in set(A)}
for a in A:
    B[a] += 1
print((sum(sorted(B.values())[:-K])))

N, K = list(map(int, input().split()))
B = {}
for i in input().split():
    if i in B:
        B[i] += 1
    else:
        B[i] = 1
print((sum(sorted(B.values())[:-K])))

-A = list(map(int, input().split())) -B = {i: 0 for i in set(A)} -for a in A: -    B[a] += 1 +B = {} +for i in input().split(): +    if i in B: +        B[i] += 1 +    else: +        B[i] = 1