# -*- coding: utf-8 -*-



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

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



dict_A = {}

for a in A:

    if a not in dict_A:

        dict_A[a] = 1

    else:

        dict_A[a] += 1



if len(list(dict_A.keys())) <= k:

    print((0))

    exit()



sorted_A = sorted(list(dict_A.items()), key=lambda x: x[1])



ans = 0

for i in range(len(list(dict_A.keys()))-k):

    ans += sorted_A[i][1]



print(ans)

# -*- coding: utf-8 -*-



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

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



B = {}

for a in A:

    if a not in B:

        B[a] = 1

    else:

        B[a] += 1



C = sorted(list(B.items()), key=lambda x: x[1])

if len(C) <= k:

    print((0))

else:

    ans = 0

    for i in range(len(C)-k):

        ans += C[i][1]

    print(ans)

# -*- coding: utf-8 -*-
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
dict_A = {}
for a in A:
    if a not in dict_A:
        dict_A[a] = 1
    else:
        dict_A[a] += 1
if len(list(dict_A.keys())) <= k:
    print((0))
    exit()
sorted_A = sorted(list(dict_A.items()), key=lambda x: x[1])
ans = 0
for i in range(len(list(dict_A.keys())) - k):
    ans += sorted_A[i][1]
print(ans)

# -*- coding: utf-8 -*-
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = {}
for a in A:
    if a not in B:
        B[a] = 1
    else:
        B[a] += 1
C = sorted(list(B.items()), key=lambda x: x[1])
if len(C) <= k:
    print((0))
else:
    ans = 0
    for i in range(len(C) - k):
        ans += C[i][1]
    print(ans)

-dict_A = {} +B = {} -    if a not in dict_A: -        dict_A[a] = 1 +    if a not in B: +        B[a] = 1 -        dict_A[a] += 1 -if len(list(dict_A.keys())) <= k: +        B[a] += 1 +C = sorted(list(B.items()), key=lambda x: x[1]) +if len(C) <= k: -    exit() -sorted_A = sorted(list(dict_A.items()), key=lambda x: x[1]) -ans = 0 -for i in range(len(list(dict_A.keys())) - k): -    ans += sorted_A[i][1] -print(ans) +else: +    ans = 0 +    for i in range(len(C) - k): +        ans += C[i][1] +    print(ans)