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()))



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()))
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()))
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:])))

-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:]))) +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:])))