n,k,*a=list(map(int,open(0).read().split()))

d={}

for i in a:

    d[i]=d.get(i,0)+1

b=list(d.values())

b.sort()

print((sum(b[:-k])))
from collections import *

_,k,*a = list(map(int,open(0).read().split()))

print((sum(sorted(Counter(a).values())[:-k])))
n, k, *a = list(map(int, open(0).read().split()))
d = {}
for i in a:
    d[i] = d.get(i, 0) + 1
b = list(d.values())
b.sort()
print((sum(b[:-k])))

from collections import *

_, k, *a = list(map(int, open(0).read().split()))
print((sum(sorted(Counter(a).values())[:-k])))

-n, k, *a = list(map(int, open(0).read().split())) -d = {} -for i in a: -    d[i] = d.get(i, 0) + 1 -b = list(d.values()) -b.sort() -print((sum(b[:-k]))) +from collections import * + +_, k, *a = list(map(int, open(0).read().split())) +print((sum(sorted(Counter(a).values())[:-k])))