from collections import Counter



n, k = [int(i) for i in input().split()]

a = [int(i) for i in input().split()]

set_a = set(a)



count_list = []

if len(set_a) <= k:

    print((0))

else:

    a = Counter(a)

    cost = 0

    for (v, c) in a.most_common()[k:]:

        cost += c

    print(cost)
from collections import Counter



n, k = [int(i) for i in input().split()]

a = Counter([int(i) for i in input().split()])



cost = 0

print((sum(c for (v, c) in a.most_common()[k:])))

from collections import Counter

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
set_a = set(a)
count_list = []
if len(set_a) <= k:
    print((0))
else:
    a = Counter(a)
    cost = 0
    for (v, c) in a.most_common()[k:]:
        cost += c
    print(cost)

from collections import Counter

n, k = [int(i) for i in input().split()]
a = Counter([int(i) for i in input().split()])
cost = 0
print((sum(c for (v, c) in a.most_common()[k:])))

-a = [int(i) for i in input().split()] -set_a = set(a) -count_list = [] -if len(set_a) <= k: -    print((0)) -else: -    a = Counter(a) -    cost = 0 -    for (v, c) in a.most_common()[k:]: -        cost += c -    print(cost) +a = Counter([int(i) for i in input().split()]) +cost = 0 +print((sum(c for (v, c) in a.most_common()[k:])))