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:

    d = {i:0 for i in set(A)}

    for a in A:

        d[a] += 1

    ans = list(d.values())

    ans.sort(reverse = True)

    print((sum(ans[k:])))
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:
    d = {i: 0 for i in set(A)}
    for a in A:
        d[a] += 1
    ans = list(d.values())
    ans.sort(reverse=True)
    print((sum(ans[k:])))

-N, K = list(map(int, input().split())) +n, k = list(map(int, input().split())) -Ad = {x: 0 for x in set(A)} -if len(set(A)) <= K: +if len(set(A)) <= k: -    count = 0 +    d = {i: 0 for i in set(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) +        d[a] += 1 +    ans = list(d.values()) +    ans.sort(reverse=True) +    print((sum(ans[k:])))