from collections import Counter

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

a = Counter(list(map(int, input().split())))

if N == K:

    print((0))

else:

    num = list(a.values())

    if len(num) <= K:

        print((0))

    else:

        print((sum(sorted(num)[:-K])))
from collections import Counter

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

A = sorted(list(Counter(list(map(int, input().split()))).values()))

if N == K:

    print((0))

elif len(A) <= K:

    print((0))

else:

    print((sum(A[:-K])))
from collections import Counter

N, K = list(map(int, input().split()))
a = Counter(list(map(int, input().split())))
if N == K:
    print((0))
else:
    num = list(a.values())
    if len(num) <= K:
        print((0))
    else:
        print((sum(sorted(num)[:-K])))

from collections import Counter

N, K = list(map(int, input().split()))
A = sorted(list(Counter(list(map(int, input().split()))).values()))
if N == K:
    print((0))
elif len(A) <= K:
    print((0))
else:
    print((sum(A[:-K])))

-a = Counter(list(map(int, input().split()))) +A = sorted(list(Counter(list(map(int, input().split()))).values())) +elif len(A) <= K: +    print((0)) -    num = list(a.values()) -    if len(num) <= K: -        print((0)) -    else: -        print((sum(sorted(num)[:-K]))) +    print((sum(A[:-K])))