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

a = list(map(int, input().split()))



from collections import Counter

c = Counter(a)

key = []

value = []

for i, j in sorted(list(c.items()), key=lambda x: x[1]):

  key.append(i)

  value.append(j)



print((sum(value[:(len(key)-k)])))
n, k = list(map(int, input().split()))

a = list(map(int, input().split()))



from collections import Counter

c = Counter(a)

cnts = []

for i, j in list(c.items()):

  cnts.append(j)



print((sum(sorted(cnts)[:-k])))
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
from collections import Counter

c = Counter(a)
key = []
value = []
for i, j in sorted(list(c.items()), key=lambda x: x[1]):
    key.append(i)
    value.append(j)
print((sum(value[: (len(key) - k)])))

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
from collections import Counter

c = Counter(a)
cnts = []
for i, j in list(c.items()):
    cnts.append(j)
print((sum(sorted(cnts)[:-k])))

-key = [] -value = [] -for i, j in sorted(list(c.items()), key=lambda x: x[1]): -    key.append(i) -    value.append(j) -print((sum(value[: (len(key) - k)]))) +cnts = [] +for i, j in list(c.items()): +    cnts.append(j) +print((sum(sorted(cnts)[:-k])))