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

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

D = dict.fromkeys(list(range(1,n+1)),0)

ans = 0

for a in A:

  D[a] += 1

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

for i in range(n-k):

  ans += D[i][1]

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

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

L = [0] * n

ans = 0



for a in A:

  L[a-1] += 1

L = sorted(L)

for i in range(n-k):

  ans += L[i]



print(ans)
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
D = dict.fromkeys(list(range(1, n + 1)), 0)
ans = 0
for a in A:
    D[a] += 1
D = sorted(list(D.items()), key=lambda x: x[1])
for i in range(n - k):
    ans += D[i][1]
print(ans)

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
L = [0] * n
ans = 0
for a in A:
    L[a - 1] += 1
L = sorted(L)
for i in range(n - k):
    ans += L[i]
print(ans)

-D = dict.fromkeys(list(range(1, n + 1)), 0) +L = [0] * n -    D[a] += 1 -D = sorted(list(D.items()), key=lambda x: x[1]) +    L[a - 1] += 1 +L = sorted(L) -    ans += D[i][1] +    ans += L[i]