from collections import Counter, deque



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

a = [int(i) for i in input().split()]



ans = 0

d = deque(sorted(Counter(a).values()))

while k < len(d):

    ans += d.popleft()

else:

    print(ans)
from collections import Counter as C



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

a = [int(i) for i in input().split()]



c = list(C(a).values())

d = len(c) - k

if 0 < d:

    print((sum(sorted(c)[:d])))

else:

    print((0))
from collections import Counter, deque

_, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
ans = 0
d = deque(sorted(Counter(a).values()))
while k < len(d):
    ans += d.popleft()
else:
    print(ans)

from collections import Counter as C

_, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
c = list(C(a).values())
d = len(c) - k
if 0 < d:
    print((sum(sorted(c)[:d])))
else:
    print((0))

-from collections import Counter, deque +from collections import Counter as C -ans = 0 -d = deque(sorted(Counter(a).values())) -while k < len(d): -    ans += d.popleft() +c = list(C(a).values()) +d = len(c) - k +if 0 < d: +    print((sum(sorted(c)[:d]))) -    print(ans) +    print((0))