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

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

count = [0]*max(A)

for i in A:

  count[i-1] += 1

print((sum(sorted(count,reverse=True)[K:])))
import collections as c

n,k=list(map(int,input().split()));a=c.Counter(list(map(int,input().split())))

print(([0,sum(sorted([i for i in list(a.values())])[:len(a)-k])][len(a)>k]))
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
count = [0] * max(A)
for i in A:
    count[i - 1] += 1
print((sum(sorted(count, reverse=True)[K:])))

import collections as c

n, k = list(map(int, input().split()))
a = c.Counter(list(map(int, input().split())))
print(([0, sum(sorted([i for i in list(a.values())])[: len(a) - k])][len(a) > k]))

-N, K = list(map(int, input().split())) -A = list(map(int, input().split())) -count = [0] * max(A) -for i in A: -    count[i - 1] += 1 -print((sum(sorted(count, reverse=True)[K:]))) +import collections as c + +n, k = list(map(int, input().split())) +a = c.Counter(list(map(int, input().split()))) +print(([0, sum(sorted([i for i in list(a.values())])[: len(a) - k])][len(a) > k]))