N, K = list(map(int, input().split()))

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



B = [0] * (N + 1)

for i in range(N):

    B[A[i]] += 1

B = [x for x in sorted(B, reverse=True) if x > 0]



ans = 0

while len(B) - K > 0:

    ans += B.pop()

print(ans)

from collections import Counter

from operator import itemgetter



N, K = list(map(int, input().split()))

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



c = sorted(list(Counter(A).values()), reverse=True)

print((sum([x for x in c[K:]])))
N, K = list(map(int, input().split()))
A = [int(x) for x in input().split()]
B = [0] * (N + 1)
for i in range(N):
    B[A[i]] += 1
B = [x for x in sorted(B, reverse=True) if x > 0]
ans = 0
while len(B) - K > 0:
    ans += B.pop()
print(ans)

from collections import Counter
from operator import itemgetter

N, K = list(map(int, input().split()))
A = [int(x) for x in input().split()]
c = sorted(list(Counter(A).values()), reverse=True)
print((sum([x for x in c[K:]])))

+from collections import Counter +from operator import itemgetter + -B = [0] * (N + 1) -for i in range(N): -    B[A[i]] += 1 -B = [x for x in sorted(B, reverse=True) if x > 0] -ans = 0 -while len(B) - K > 0: -    ans += B.pop() -print(ans) +c = sorted(list(Counter(A).values()), reverse=True) +print((sum([x for x in c[K:]])))