import collections

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

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

c = collections.Counter(A).most_common()[::-1]

k = len(c)

if k<=K:print((0))

else: print((sum([e[1] for e in c[:k-K]])))
from collections import Counter

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

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

C = Counter(A).most_common()

if len(C)<=K:

    print((0))

else:

    ans = 0

    for c in C[:K]:

        ans+=c[1]

    print((N-ans))
import collections

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
c = collections.Counter(A).most_common()[::-1]
k = len(c)
if k <= K:
    print((0))
else:
    print((sum([e[1] for e in c[: k - K]])))

from collections import Counter

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
C = Counter(A).most_common()
if len(C) <= K:
    print((0))
else:
    ans = 0
    for c in C[:K]:
        ans += c[1]
    print((N - ans))

-import collections +from collections import Counter -c = collections.Counter(A).most_common()[::-1] -k = len(c) -if k <= K: +C = Counter(A).most_common() +if len(C) <= K: -    print((sum([e[1] for e in c[: k - K]]))) +    ans = 0 +    for c in C[:K]: +        ans += c[1] +    print((N - ans))