from collections import Counter



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

arr = Counter(input().split())

chenge = len(arr) - k

count = 0

for k, v in arr.most_common()[::-1]:

  if chenge > 0:

    count += v

    chenge -= 1

print(count)    

  

  

  
from collections import Counter



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

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

A = Counter(A).most_common() # 降順 type=list



# 数が少ないものを変更する

cnt = A[K:]

print((sum([v for k, v in cnt])))

from collections import Counter

n, k = list(map(int, input().split()))
arr = Counter(input().split())
chenge = len(arr) - k
count = 0
for k, v in arr.most_common()[::-1]:
    if chenge > 0:
        count += v
        chenge -= 1
print(count)

from collections import Counter

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = Counter(A).most_common()  # 降順 type=list
# 数が少ないものを変更する
cnt = A[K:]
print((sum([v for k, v in cnt])))

-n, k = list(map(int, input().split())) -arr = Counter(input().split()) -chenge = len(arr) - k -count = 0 -for k, v in arr.most_common()[::-1]: -    if chenge > 0: -        count += v -        chenge -= 1 -print(count) +N, K = list(map(int, input().split())) +A = list(map(int, input().split())) +A = Counter(A).most_common()  # 降順 type=list +# 数が少ないものを変更する +cnt = A[K:] +print((sum([v for k, v in cnt])))