from collections import Counter



n, m = list(map(int, input().split()))

dic = Counter(list(map(int, input().split())))

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



res = 0

for i, x in enumerate(lis):

    if i < m:

        continue

    else:

       res += x[1]

print(res)

from collections import Counter



n, m = list(map(int, input().split()))

dic = Counter(list(map(int, input().split())))

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



res = 0

for i in range(min(m, len(lis))):

    res += lis[i][1]

print((n - res))

from collections import Counter

n, m = list(map(int, input().split()))
dic = Counter(list(map(int, input().split())))
lis = sorted(list(dic.items()), key=lambda x: x[1], reverse=True)
res = 0
for i, x in enumerate(lis):
    if i < m:
        continue
    else:
        res += x[1]
print(res)

from collections import Counter

n, m = list(map(int, input().split()))
dic = Counter(list(map(int, input().split())))
lis = sorted(list(dic.items()), key=lambda x: x[1], reverse=True)
res = 0
for i in range(min(m, len(lis))):
    res += lis[i][1]
print((n - res))

-for i, x in enumerate(lis): -    if i < m: -        continue -    else: -        res += x[1] -print(res) +for i in range(min(m, len(lis))): +    res += lis[i][1] +print((n - res))