from collections import Counter

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

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

x = len(dic) - k

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

ans = 0

for i in range(x):

    ans += lis[i][1]

print(ans)
from collections import Counter

from operator import itemgetter

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

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

x = len(dic) - k

lis = sorted(list(dic.items()), key = itemgetter(1))

ans = 0

for i in range(x):

    ans += lis[i][1]

print(ans)
from collections import Counter

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

from collections import Counter
from operator import itemgetter

n, k = list(map(int, input().split()))
dic = Counter(list(map(int, input().split())))
x = len(dic) - k
lis = sorted(list(dic.items()), key=itemgetter(1))
ans = 0
for i in range(x):
    ans += lis[i][1]
print(ans)

+from operator import itemgetter -lis = sorted(list(dic.items()), key=lambda z: z[1]) +lis = sorted(list(dic.items()), key=itemgetter(1))