N,K = list(map(int,input().split()))

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



Ad = {x:0 for x in set(A)}

if len(set(A)) <= K:

    print((0))

else:

    count = 0

    for a in A:

        Ad[a] += 1

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

    for i in range(len(set(A))-K):

        count += Ad[i][1]

    print(count)

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

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



if(len(set(a)) <= k):

    print((0))

else:

    dic_a = {x:0 for x in set(a)}

    for i in a:

        dic_a[i] += 1

    sum = 0

    a = sorted(list(dic_a.values()),reverse=True)

    for i in range(k,len(a)):

        sum += a[i]

    print(sum)
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
Ad = {x: 0 for x in set(A)}
if len(set(A)) <= K:
    print((0))
else:
    count = 0
    for a in A:
        Ad[a] += 1
    Ad = sorted(list(Ad.items()), key=lambda x: x[1])
    for i in range(len(set(A)) - K):
        count += Ad[i][1]
    print(count)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if len(set(a)) <= k:
    print((0))
else:
    dic_a = {x: 0 for x in set(a)}
    for i in a:
        dic_a[i] += 1
    sum = 0
    a = sorted(list(dic_a.values()), reverse=True)
    for i in range(k, len(a)):
        sum += a[i]
    print(sum)

-N, K = list(map(int, input().split())) -A = list(map(int, input().split())) -Ad = {x: 0 for x in set(A)} -if len(set(A)) <= K: +n, k = list(map(int, input().split())) +a = list(map(int, input().split())) +if len(set(a)) <= k: -    count = 0 -    for a in A: -        Ad[a] += 1 -    Ad = sorted(list(Ad.items()), key=lambda x: x[1]) -    for i in range(len(set(A)) - K): -        count += Ad[i][1] -    print(count) +    dic_a = {x: 0 for x in set(a)} +    for i in a: +        dic_a[i] += 1 +    sum = 0 +    a = sorted(list(dic_a.values()), reverse=True) +    for i in range(k, len(a)): +        sum += a[i] +    print(sum)