import collections

from collections import  OrderedDict



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

val = input().split()



count_dict = collections.Counter(val)



cant = 0



if len(count_dict) <= num[1]:

    print((0))

else:

    sort_dict = OrderedDict(sorted(list(count_dict.items()), key=lambda x:x[1], reverse= True))

    value_dict = list(sort_dict.values())

    print((sum(list(value_dict)[num[1]:])))
import collections



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

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

_dict = collections.Counter(array)



res = 0

tmp = len(list(_dict.values()))

if len(list(_dict.values())) < k:

    print((0))

else:

    sort_dict = collections.OrderedDict(sorted(list(_dict.items()), key=lambda x: x[1], reverse=True))

    value_dict = list(sort_dict.values())

    print((sum(list(value_dict)[k:])))
import collections
from collections import OrderedDict

num = [int(x) for x in input().split()]
val = input().split()
count_dict = collections.Counter(val)
cant = 0
if len(count_dict) <= num[1]:
    print((0))
else:
    sort_dict = OrderedDict(
        sorted(list(count_dict.items()), key=lambda x: x[1], reverse=True)
    )
    value_dict = list(sort_dict.values())
    print((sum(list(value_dict)[num[1] :])))

import collections

n, k = list(map(int, input().split()))
array = [int(x) for x in input().split()]
_dict = collections.Counter(array)
res = 0
tmp = len(list(_dict.values()))
if len(list(_dict.values())) < k:
    print((0))
else:
    sort_dict = collections.OrderedDict(
        sorted(list(_dict.items()), key=lambda x: x[1], reverse=True)
    )
    value_dict = list(sort_dict.values())
    print((sum(list(value_dict)[k:])))

-from collections import OrderedDict -num = [int(x) for x in input().split()] -val = input().split() -count_dict = collections.Counter(val) -cant = 0 -if len(count_dict) <= num[1]: +n, k = list(map(int, input().split())) +array = [int(x) for x in input().split()] +_dict = collections.Counter(array) +res = 0 +tmp = len(list(_dict.values())) +if len(list(_dict.values())) < k: -    sort_dict = OrderedDict( -        sorted(list(count_dict.items()), key=lambda x: x[1], reverse=True) +    sort_dict = collections.OrderedDict( +        sorted(list(_dict.items()), key=lambda x: x[1], reverse=True) -    print((sum(list(value_dict)[num[1] :]))) +    print((sum(list(value_dict)[k:])))