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

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



b = [0]*200000

c = []

ans = 0



for x in a:

    b[x-1] += 1



for x in b:

    if x > 0:

        c.append(x)



c.sort()



y = len(c) - k



if y > 0:

    ans = sum(c[:y])



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

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

b = [0]*(n+1)

for x in a:

    b[x]+=1

b.sort(reverse=1)

print((sum(b[k:])))







n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0] * 200000
c = []
ans = 0
for x in a:
    b[x - 1] += 1
for x in b:
    if x > 0:
        c.append(x)
c.sort()
y = len(c) - k
if y > 0:
    ans = sum(c[:y])
print(ans)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0] * (n + 1)
for x in a:
    b[x] += 1
b.sort(reverse=1)
print((sum(b[k:])))

-b = [0] * 200000 -c = [] -ans = 0 +b = [0] * (n + 1) -    b[x - 1] += 1 -for x in b: -    if x > 0: -        c.append(x) -c.sort() -y = len(c) - k -if y > 0: -    ans = sum(c[:y]) -print(ans) +    b[x] += 1 +b.sort(reverse=1) +print((sum(b[k:])))