import bisect



N,K = [int(zz) for zz in input().split()]

A = [int(zz) for zz in input().split()]

B = set(A)



A.sort()

ans = []

for i in B:

    p = bisect.bisect_right(A, i) - bisect.bisect_left(A, i)

    ans.append(p)



ans.sort()

j = 0

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

    j += ans[i]

print(j)

from collections import Counter



N,K = [int(zz) for zz in input().split()]

A = [int(zz) for zz in input().split()]



tmp = Counter(A).most_common()[::-1]

ans = 0

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

    ans += tmp[i][1]



print(ans)

import bisect

N, K = [int(zz) for zz in input().split()]
A = [int(zz) for zz in input().split()]
B = set(A)
A.sort()
ans = []
for i in B:
    p = bisect.bisect_right(A, i) - bisect.bisect_left(A, i)
    ans.append(p)
ans.sort()
j = 0
for i in range(len(B) - K):
    j += ans[i]
print(j)

from collections import Counter

N, K = [int(zz) for zz in input().split()]
A = [int(zz) for zz in input().split()]
tmp = Counter(A).most_common()[::-1]
ans = 0
for i in range(len(tmp) - K):
    ans += tmp[i][1]
print(ans)

-import bisect +from collections import Counter -B = set(A) -A.sort() -ans = [] -for i in B: -    p = bisect.bisect_right(A, i) - bisect.bisect_left(A, i) -    ans.append(p) -ans.sort() -j = 0 -for i in range(len(B) - K): -    j += ans[i] -print(j) +tmp = Counter(A).most_common()[::-1] +ans = 0 +for i in range(len(tmp) - K): +    ans += tmp[i][1] +print(ans)