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

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

from collections import Counter

C = Counter(A).most_common()

dif = len(C) - k

if dif <= 0:

	print((0))

else:

	s = 0

	for i in range(dif):

		s += C[-(i + 1)][1]

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

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

from collections import Counter

C = Counter(A)

dif = len(C) - k

if dif <= 0:

	print((0))

else:

	print((sum(sorted(C.values())[:dif])))
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
from collections import Counter

C = Counter(A).most_common()
dif = len(C) - k
if dif <= 0:
    print((0))
else:
    s = 0
    for i in range(dif):
        s += C[-(i + 1)][1]
    print(s)

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
from collections import Counter

C = Counter(A)
dif = len(C) - k
if dif <= 0:
    print((0))
else:
    print((sum(sorted(C.values())[:dif])))

-C = Counter(A).most_common() +C = Counter(A) -    s = 0 -    for i in range(dif): -        s += C[-(i + 1)][1] -    print(s) +    print((sum(sorted(C.values())[:dif])))