from collections import Counter

import numpy as np



n,k = input().split()

n = int(n)

k = int(k)

a_list = input().split()

count = np.array(list(Counter(a_list).values()))

count.sort()

count = count[::-1]

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



n,k = list([int(x) for x in input().split()])

a   = list([int(x) for x in input().split()])



print((sum(sorted(list(Counter(a).values()),reverse=True)[k:])))
from collections import Counter
import numpy as np

n, k = input().split()
n = int(n)
k = int(k)
a_list = input().split()
count = np.array(list(Counter(a_list).values()))
count.sort()
count = count[::-1]
print((count[k:].sum()))

from collections import Counter

n, k = list([int(x) for x in input().split()])
a = list([int(x) for x in input().split()])
print((sum(sorted(list(Counter(a).values()), reverse=True)[k:])))

-import numpy as np -n, k = input().split() -n = int(n) -k = int(k) -a_list = input().split() -count = np.array(list(Counter(a_list).values())) -count.sort() -count = count[::-1] -print((count[k:].sum())) +n, k = list([int(x) for x in input().split()]) +a = list([int(x) for x in input().split()]) +print((sum(sorted(list(Counter(a).values()), reverse=True)[k:])))