import collections



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

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



number = len(set(A))



c = collections.Counter(A)

values,counts=list(zip(*c.most_common()))

count = 0

for i in range(number):

    if number <= K:

        print(count)

        break

    count += counts[-(i+1)]

    number -= 1
from collections import Counter



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

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



c = Counter(A)

d = c.most_common()[::-1]



ans = 0

for i in range(len(set(A))-K):

    ans += d[i][1]



print(ans)
import collections

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
number = len(set(A))
c = collections.Counter(A)
values, counts = list(zip(*c.most_common()))
count = 0
for i in range(number):
    if number <= K:
        print(count)
        break
    count += counts[-(i + 1)]
    number -= 1

from collections import Counter

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
c = Counter(A)
d = c.most_common()[::-1]
ans = 0
for i in range(len(set(A)) - K):
    ans += d[i][1]
print(ans)

-import collections +from collections import Counter -number = len(set(A)) -c = collections.Counter(A) -values, counts = list(zip(*c.most_common())) -count = 0 -for i in range(number): -    if number <= K: -        print(count) -        break -    count += counts[-(i + 1)] -    number -= 1 +c = Counter(A) +d = c.most_common()[::-1] +ans = 0 +for i in range(len(set(A)) - K): +    ans += d[i][1] +print(ans)