from collections import Counter

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

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

d=Counter(a)

d=sorted(list(d.items()),key=lambda x:x[1])

ans=0

for i in range(len(d)-K):

        ans+=d[i][1]

print(ans)
from collections import Counter

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

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

d=Counter(a)

ans=sum(sorted(list(d.values()),reverse=1)[:K])

print((N-ans))
from collections import Counter

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
d = Counter(a)
d = sorted(list(d.items()), key=lambda x: x[1])
ans = 0
for i in range(len(d) - K):
    ans += d[i][1]
print(ans)

from collections import Counter

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
d = Counter(a)
ans = sum(sorted(list(d.values()), reverse=1)[:K])
print((N - ans))

-d = sorted(list(d.items()), key=lambda x: x[1]) -ans = 0 -for i in range(len(d) - K): -    ans += d[i][1] -print(ans) +ans = sum(sorted(list(d.values()), reverse=1)[:K]) +print((N - ans))