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

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

from collections import Counter

data=Counter(a)

data_i=sorted(list(data.items()),key=lambda x:x[1])

count=0

set_a=list(set(a))

if k<len(set_a):

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

        count+=data_i[i][1]

    print(count)

else:

    print((0))

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

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

import collections

data=collections.Counter(a)

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

count=0

if len(data)<=k:

    print((0))

    exit()

else:

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

        count+=data[i][1]

print(count)

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

data = Counter(a)
data_i = sorted(list(data.items()), key=lambda x: x[1])
count = 0
set_a = list(set(a))
if k < len(set_a):
    for i in range(len(set_a) - k):
        count += data_i[i][1]
    print(count)
else:
    print((0))

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

data = collections.Counter(a)
data = sorted(list(data.items()), key=lambda x: x[1])
count = 0
if len(data) <= k:
    print((0))
    exit()
else:
    for i in range(len(data) - k):
        count += data[i][1]
print(count)

-from collections import Counter +import collections -data = Counter(a) -data_i = sorted(list(data.items()), key=lambda x: x[1]) +data = collections.Counter(a) +data = sorted(list(data.items()), key=lambda x: x[1]) -set_a = list(set(a)) -if k < len(set_a): -    for i in range(len(set_a) - k): -        count += data_i[i][1] -    print(count) +if len(data) <= k: +    print((0)) +    exit() -    print((0)) +    for i in range(len(data) - k): +        count += data[i][1] +print(count)