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

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

d = {}

for a in A:

  if(a in d):

    d[a] += 1

  else:

    d[a] = 1



print((sum(sorted(d.values())[:-K])))
from collections import Counter



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

A = input().split()



a = Counter(A)

print((sum(sorted(list(a.values()), reverse = True)[K:])))
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
d = {}
for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1
print((sum(sorted(d.values())[:-K])))

from collections import Counter

N, K = list(map(int, input().split()))
A = input().split()
a = Counter(A)
print((sum(sorted(list(a.values()), reverse=True)[K:])))

+from collections import Counter + -A = list(map(int, input().split())) -d = {} -for a in A: -    if a in d: -        d[a] += 1 -    else: -        d[a] = 1 -print((sum(sorted(d.values())[:-K]))) +A = input().split() +a = Counter(A) +print((sum(sorted(list(a.values()), reverse=True)[K:])))