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

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

d = {}

for i in a:

    if i not in d:

        d[i] = 1

    else:

        d[i] += 1



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

ans = 0

if len(d) <= k:

    print((0))

else:

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

        ans += d[-i-1][1]

    print(ans)
import collections



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

a = input().split()

a = sorted(list(collections.Counter(a).values()), reverse=True)

s = sum(a[:k])



print((0 if s == n else n - s))
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
d = {}
for i in a:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1
d = sorted(list(d.items()), key=lambda x: x[1], reverse=True)
ans = 0
if len(d) <= k:
    print((0))
else:
    for i in range(len(d) - k):
        ans += d[-i - 1][1]
    print(ans)

import collections

n, k = list(map(int, input().split()))
a = input().split()
a = sorted(list(collections.Counter(a).values()), reverse=True)
s = sum(a[:k])
print((0 if s == n else n - s))

+import collections + -a = list(map(int, input().split())) -d = {} -for i in a: -    if i not in d: -        d[i] = 1 -    else: -        d[i] += 1 -d = sorted(list(d.items()), key=lambda x: x[1], reverse=True) -ans = 0 -if len(d) <= k: -    print((0)) -else: -    for i in range(len(d) - k): -        ans += d[-i - 1][1] -    print(ans) +a = input().split() +a = sorted(list(collections.Counter(a).values()), reverse=True) +s = sum(a[:k]) +print((0 if s == n else n - s))