from collections import Counter

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

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



c = Counter(A).most_common()

c.sort(key=lambda x: -x[1])

ans = 0

while len(c) > K:

    ans += c.pop()[1]

print(ans)
from collections import Counter

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

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

print((sum(sorted(Counter(A).values())[:-K])))
from collections import Counter

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
c = Counter(A).most_common()
c.sort(key=lambda x: -x[1])
ans = 0
while len(c) > K:
    ans += c.pop()[1]
print(ans)

from collections import Counter

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

-c = Counter(A).most_common() -c.sort(key=lambda x: -x[1]) -ans = 0 -while len(c) > K: -    ans += c.pop()[1] -print(ans) +print((sum(sorted(Counter(A).values())[:-K])))