from collections import Counter

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

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

ctr = Counter(A)



ans = 0

for i,(k,v) in enumerate(ctr.most_common()):

    if i < K: continue

    ans += v

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

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

from collections import Counter

ctr = Counter(A)

if len(ctr) <= K:

    print((0))

    exit()



l = len(ctr) - K

ans = sum(sorted(ctr.values())[:l])

print(ans)
from collections import Counter

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
ctr = Counter(A)
ans = 0
for i, (k, v) in enumerate(ctr.most_common()):
    if i < K:
        continue
    ans += v
print(ans)

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
from collections import Counter

ctr = Counter(A)
if len(ctr) <= K:
    print((0))
    exit()
l = len(ctr) - K
ans = sum(sorted(ctr.values())[:l])
print(ans)

+N, K = list(map(int, input().split())) +A = list(map(int, input().split())) -N, K = list(map(int, input().split())) -A = list(map(int, input().split())) -ans = 0 -for i, (k, v) in enumerate(ctr.most_common()): -    if i < K: -        continue -    ans += v +if len(ctr) <= K: +    print((0)) +    exit() +l = len(ctr) - K +ans = sum(sorted(ctr.values())[:l])