# ARC086C - Not so Diverse (ABC081C)

n, k = list(map(int, input().rstrip().split()))

lst = sorted(list(map(int, input().rstrip().split())))

dic = {}

for i in lst:

    if i not in dic:

        dic[i] = 1

    else:

        dic[i] += 1



cnt = sorted([i for i in list(dic.values())], reverse=True)

print((sum(cnt[k:])))
from collections import Counter



n, k = list(map(int, input().rstrip().split()))

lst = list(map(int, input().rstrip().split()))

cnt = sorted(list(Counter(lst).values()), reverse=True)

print((sum(cnt[k:])))
# ARC086C - Not so Diverse (ABC081C)
n, k = list(map(int, input().rstrip().split()))
lst = sorted(list(map(int, input().rstrip().split())))
dic = {}
for i in lst:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1
cnt = sorted([i for i in list(dic.values())], reverse=True)
print((sum(cnt[k:])))

from collections import Counter

n, k = list(map(int, input().rstrip().split()))
lst = list(map(int, input().rstrip().split()))
cnt = sorted(list(Counter(lst).values()), reverse=True)
print((sum(cnt[k:])))

-# ARC086C - Not so Diverse (ABC081C) +from collections import Counter + -lst = sorted(list(map(int, input().rstrip().split()))) -dic = {} -for i in lst: -    if i not in dic: -        dic[i] = 1 -    else: -        dic[i] += 1 -cnt = sorted([i for i in list(dic.values())], reverse=True) +lst = list(map(int, input().rstrip().split())) +cnt = sorted(list(Counter(lst).values()), reverse=True)