N, K = [int(i) for i in input().split()]

A = [int(i) for i in input().split()]



dic = {}

for i in A:

    if i in dic:

        dic[i] += 1

    else:

        dic[i] = 1



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



ans = []

for i in range(K, len(dic_sort)):

    ans.append(dic_sort[i][1])



print((sum(ans)))
from collections import Counter



N, K = [int(i) for i in input().split()]

A = [int(i) for i in input().split()]



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

ans = [cou[i][1] for i in range(K, len(cou))]

print((sum(ans)))
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
dic = {}
for i in A:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
dic_sort = sorted(list(dic.items()), key=lambda x: x[1], reverse=True)
ans = []
for i in range(K, len(dic_sort)):
    ans.append(dic_sort[i][1])
print((sum(ans)))

from collections import Counter

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
cou = sorted(list(Counter(A).items()), key=lambda x: x[1], reverse=True)
ans = [cou[i][1] for i in range(K, len(cou))]
print((sum(ans)))

+from collections import Counter + -dic = {} -for i in A: -    if i in dic: -        dic[i] += 1 -    else: -        dic[i] = 1 -dic_sort = sorted(list(dic.items()), key=lambda x: x[1], reverse=True) -ans = [] -for i in range(K, len(dic_sort)): -    ans.append(dic_sort[i][1]) +cou = sorted(list(Counter(A).items()), key=lambda x: x[1], reverse=True) +ans = [cou[i][1] for i in range(K, len(cou))]