import numpy as np

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

A = np.array(input().split(), dtype=np.int32)

counter = np.bincount(A)

counter.sort()

counter = counter[::-1] 

no_change = counter[:K].sum()

answer = N - no_change

print(answer)

import collections

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

a = input().split()

a = sorted(list(collections.Counter(a).values()))

print((sum(a[:len(a)-k])))

import numpy as np

N, K = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.int32)
counter = np.bincount(A)
counter.sort()
counter = counter[::-1]
no_change = counter[:K].sum()
answer = N - no_change
print(answer)

import collections

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

-import numpy as np +import collections -N, K = list(map(int, input().split())) -A = np.array(input().split(), dtype=np.int32) -counter = np.bincount(A) -counter.sort() -counter = counter[::-1] -no_change = counter[:K].sum() -answer = N - no_change -print(answer) +n, k = list(map(int, input().split())) +a = input().split() +a = sorted(list(collections.Counter(a).values())) +print((sum(a[: len(a) - k])))