from collections import Counter

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

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

cnts = list(Counter(a).values())

print((sum(sorted(cnts)[:-k])))
from collections import Counter

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

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

cnts = list(Counter(a).values())

print((sum(sorted(cnts, reverse=True)[k:])))
from collections import Counter

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

from collections import Counter

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

-print((sum(sorted(cnts)[:-k]))) +print((sum(sorted(cnts, reverse=True)[k:])))