from collections import Counter



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

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



D = Counter(A)

V = []

for v in list(D.values()):

    V.append(v)

V.sort(reverse=True)

print((max(n-sum(V[:k]),0)))
from collections import Counter



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

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



D = Counter(A)

V = sorted(list(D.values()),reverse=True)

print((max(n-sum(V[:k]),0)))
from collections import Counter

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
D = Counter(A)
V = []
for v in list(D.values()):
    V.append(v)
V.sort(reverse=True)
print((max(n - sum(V[:k]), 0)))

from collections import Counter

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
D = Counter(A)
V = sorted(list(D.values()), reverse=True)
print((max(n - sum(V[:k]), 0)))

-V = [] -for v in list(D.values()): -    V.append(v) -V.sort(reverse=True) +V = sorted(list(D.values()), reverse=True)