from collections import defaultdict

from operator import itemgetter



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

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

cnt_d = defaultdict(lambda: 0)

for ai in a:

    cnt_d[ai] += 1



cnt_l = sorted(list(cnt_d.items()), key=itemgetter(1))

ans = sum([v for k,v in cnt_l[:-K]])

print(ans)

from collections import defaultdict



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

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

cnt_d = defaultdict(lambda: 0)

for ai in a:

    cnt_d[ai] += 1



cnt_v = sorted([v for k,v in list(cnt_d.items())])

print((sum(cnt_v[:-K])))

from collections import defaultdict
from operator import itemgetter

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt_d = defaultdict(lambda: 0)
for ai in a:
    cnt_d[ai] += 1
cnt_l = sorted(list(cnt_d.items()), key=itemgetter(1))
ans = sum([v for k, v in cnt_l[:-K]])
print(ans)

from collections import defaultdict

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
cnt_d = defaultdict(lambda: 0)
for ai in a:
    cnt_d[ai] += 1
cnt_v = sorted([v for k, v in list(cnt_d.items())])
print((sum(cnt_v[:-K])))

-from operator import itemgetter -cnt_l = sorted(list(cnt_d.items()), key=itemgetter(1)) -ans = sum([v for k, v in cnt_l[:-K]]) -print(ans) +cnt_v = sorted([v for k, v in list(cnt_d.items())]) +print((sum(cnt_v[:-K])))