from collections import Counter



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

A = Counter([int(i) for i in input().split()]).most_common()



count = 0

if len(A) > k:

    for i in range(len(A) - k):

        count += A[k + i][1]

        

print(count)
from collections import Counter

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

A = Counter([int(i) for i in input().split()]).most_common()

cnt = 0

for a in A[K:]:

    cnt += a[1]

print(cnt)
from collections import Counter

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

from collections import Counter

N, K = list(map(int, input().split()))
A = Counter([int(i) for i in input().split()]).most_common()
cnt = 0
for a in A[K:]:
    cnt += a[1]
print(cnt)

-n, k = list(map(int, input().split())) +N, K = list(map(int, input().split())) -count = 0 -if len(A) > k: -    for i in range(len(A) - k): -        count += A[k + i][1] -print(count) +cnt = 0 +for a in A[K:]: +    cnt += a[1] +print(cnt)