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

A = input().split()

D = {}



for i in range(N):

	if A[i] in list(D.keys()):

		D[A[i]] += 1

	else:

		D[A[i]] = 1



ans = 0

if len(D) > K:

	D = sorted(D.values())

	for i in range(len(D) - K):

		ans += D[i]



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

A = input().split()

D = {}



for i in range(N):

	if A[i] in list(D.keys()):

		D[A[i]] += 1

	else:

		D[A[i]] = 1



ans = 0

if len(D) > K:

	D = sorted(list(D.values()),reverse = True)

	ans = sum(D[K:])



print(ans)
N, K = list(map(int, input().split()))
A = input().split()
D = {}
for i in range(N):
    if A[i] in list(D.keys()):
        D[A[i]] += 1
    else:
        D[A[i]] = 1
ans = 0
if len(D) > K:
    D = sorted(D.values())
    for i in range(len(D) - K):
        ans += D[i]
print(ans)

N, K = list(map(int, input().split()))
A = input().split()
D = {}
for i in range(N):
    if A[i] in list(D.keys()):
        D[A[i]] += 1
    else:
        D[A[i]] = 1
ans = 0
if len(D) > K:
    D = sorted(list(D.values()), reverse=True)
    ans = sum(D[K:])
print(ans)

-    D = sorted(D.values()) -    for i in range(len(D) - K): -        ans += D[i] +    D = sorted(list(D.values()), reverse=True) +    ans = sum(D[K:])