from collections import Counter

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

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

l = len(A)

ans = 0

while l > K:

	ans += A[-1][1]

	del A[-1]

	l = len(A)

print(ans)

from collections import Counter

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

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

ans = 0

while len(A) > K:

	ans += A[-1][1]

	del A[-1]

print(ans)

from collections import Counter

N, K = list(map(int, input().split()))
A = Counter(list(map(int, input().split()))).most_common()
l = len(A)
ans = 0
while l > K:
    ans += A[-1][1]
    del A[-1]
    l = len(A)
print(ans)

from collections import Counter

N, K = list(map(int, input().split()))
A = Counter(list(map(int, input().split()))).most_common()
ans = 0
while len(A) > K:
    ans += A[-1][1]
    del A[-1]
print(ans)

-l = len(A) -while l > K: +while len(A) > K: -    l = len(A)