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



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

#print(a_list)



dic={}

for i in a_list:

    if i not in dic:

        dic[i]=1

    else:

        dic[i]+=1



#print(dic)

#print(len(dic))





#書き換えなくてよい    

if len(dic)<=k:

    print((0))

else:

    ans=sorted(list(dic.items()),key=lambda x:x[1],reverse=True)

    b_list=ans[k:]

    ans_sum=0

    for i in b_list:

        ans_sum+=i[1]

    print(ans_sum)

    

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



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



a_dic={}

for i in range(n):

    if a_list[i] not in a_dic:

        a_dic[a_list[i]]=1

    else:

        a_dic[a_list[i]]+=1

        





if len(a_dic)<=k:

    print((0))

else:

    #値を取り出す

    a_value=list(a_dic.values())

    

    a_value.sort(reverse=True)

    

    print((sum(a_value[k:])))

    
n, k = [int(i) for i in input().split()]
a_list = [int(i) for i in input().split()]
# print(a_list)
dic = {}
for i in a_list:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1
# print(dic)
# print(len(dic))
# 書き換えなくてよい
if len(dic) <= k:
    print((0))
else:
    ans = sorted(list(dic.items()), key=lambda x: x[1], reverse=True)
    b_list = ans[k:]
    ans_sum = 0
    for i in b_list:
        ans_sum += i[1]
    print(ans_sum)

n, k = [int(i) for i in input().split()]
a_list = [int(i) for i in input().split()]
a_dic = {}
for i in range(n):
    if a_list[i] not in a_dic:
        a_dic[a_list[i]] = 1
    else:
        a_dic[a_list[i]] += 1
if len(a_dic) <= k:
    print((0))
else:
    # 値を取り出す
    a_value = list(a_dic.values())
    a_value.sort(reverse=True)
    print((sum(a_value[k:])))

-# print(a_list) -dic = {} -for i in a_list: -    if i not in dic: -        dic[i] = 1 +a_dic = {} +for i in range(n): +    if a_list[i] not in a_dic: +        a_dic[a_list[i]] = 1 -        dic[i] += 1 -# print(dic) -# print(len(dic)) -# 書き換えなくてよい -if len(dic) <= k: +        a_dic[a_list[i]] += 1 +if len(a_dic) <= k: -    ans = sorted(list(dic.items()), key=lambda x: x[1], reverse=True) -    b_list = ans[k:] -    ans_sum = 0 -    for i in b_list: -        ans_sum += i[1] -    print(ans_sum) +    # 値を取り出す +    a_value = list(a_dic.values()) +    a_value.sort(reverse=True) +    print((sum(a_value[k:])))