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

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

D ={}

bag = 0



for i in B:

    if i in D:

        D[i] += 1

    else:

        D[i] = 1



LLL = sorted(list(D.values()))

AA = len(D) - K

if len(D) <= K:

    print((0))

else:

    for i in range(AA):

        bag += LLL[i]

    print(bag)
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)))
N, K = [int(i) for i in input().split()]
B = sorted([int(i) for i in input().split()])
D = {}
bag = 0
for i in B:
    if i in D:
        D[i] += 1
    else:
        D[i] = 1
LLL = sorted(list(D.values()))
AA = len(D) - K
if len(D) <= K:
    print((0))
else:
    for i in range(AA):
        bag += LLL[i]
    print(bag)

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)))

-B = sorted([int(i) for i in input().split()]) -D = {} -bag = 0 -for i in B: -    if i in D: -        D[i] += 1 +A = [int(i) for i in input().split()] +dic = {} +for i in A: +    if i in dic: +        dic[i] += 1 -        D[i] = 1 -LLL = sorted(list(D.values())) -AA = len(D) - K -if len(D) <= K: -    print((0)) -else: -    for i in range(AA): -        bag += LLL[i] -    print(bag) +        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)))