from collections import Counter

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

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

_, cnt = list(zip(*Counter(A).most_common()[::-1]))

print((sum(cnt[:len(cnt) - K])))
from collections import Counter

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

A = sorted(list(Counter(input().split()).values()))

print((sum(A[:len(A)-K])))
from collections import Counter

_, K = list(map(int, input().split()))
A = list(map(int, input().split()))
_, cnt = list(zip(*Counter(A).most_common()[::-1]))
print((sum(cnt[: len(cnt) - K])))

from collections import Counter

_, K = list(map(int, input().split()))
A = sorted(list(Counter(input().split()).values()))
print((sum(A[: len(A) - K])))

-A = list(map(int, input().split())) -_, cnt = list(zip(*Counter(A).most_common()[::-1])) -print((sum(cnt[: len(cnt) - K]))) +A = sorted(list(Counter(input().split()).values())) +print((sum(A[: len(A) - K])))