import bisect as bs

N, K = (int(x) for x in input().split())

A = sorted([int(x) for x in input().split()])

f = lambda X, x: bs.bisect_right(X,x)-bs.bisect_left(X,x)

cnt = sorted([f(A,a) for a in set(A)],reverse=True)

vrt = len(cnt)

print((sum(cnt[K:]) if vrt > K else 0))
from collections import Counter



def main():

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

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



    unchange = sum(tuple[1] for tuple in Counter(A).most_common(K))

    print((N-unchange))



main()
import bisect as bs

N, K = (int(x) for x in input().split())
A = sorted([int(x) for x in input().split()])
f = lambda X, x: bs.bisect_right(X, x) - bs.bisect_left(X, x)
cnt = sorted([f(A, a) for a in set(A)], reverse=True)
vrt = len(cnt)
print((sum(cnt[K:]) if vrt > K else 0))

from collections import Counter


def main():
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    unchange = sum(tuple[1] for tuple in Counter(A).most_common(K))
    print((N - unchange))


main()

-import bisect as bs +from collections import Counter -N, K = (int(x) for x in input().split()) -A = sorted([int(x) for x in input().split()]) -f = lambda X, x: bs.bisect_right(X, x) - bs.bisect_left(X, x) -cnt = sorted([f(A, a) for a in set(A)], reverse=True) -vrt = len(cnt) -print((sum(cnt[K:]) if vrt > K else 0)) + +def main(): +    N, K = list(map(int, input().split())) +    A = list(map(int, input().split())) +    unchange = sum(tuple[1] for tuple in Counter(A).most_common(K)) +    print((N - unchange)) + + +main()