from collections import Counter





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

A = sorted((v, k) for k, v in list(Counter(list(map(int, input().split()))).items()))

print((sum(v for v, k in A[: max(0, len(A) - K)])))

from collections import Counter





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

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

A_cntr = Counter(A)

print((sum(sorted(v for v in list(A_cntr.values()))[:-K])))

from collections import Counter

N, K = list(map(int, input().split()))
A = sorted((v, k) for k, v in list(Counter(list(map(int, input().split()))).items()))
print((sum(v for v, k in A[: max(0, len(A) - K)])))

from collections import Counter

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A_cntr = Counter(A)
print((sum(sorted(v for v in list(A_cntr.values()))[:-K])))

-A = sorted((v, k) for k, v in list(Counter(list(map(int, input().split()))).items())) -print((sum(v for v, k in A[: max(0, len(A) - K)]))) +A = list(map(int, input().split())) +A_cntr = Counter(A) +print((sum(sorted(v for v in list(A_cntr.values()))[:-K])))