from collections import *

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

print((sum(v for _,v in Counter(list(map(int,input().split()))).most_common()[K:])))
from collections import Counter



N, K = [int(i) for i in input().split()]

A = [int(i) for i in input().split()]



print((sum(sorted(list(Counter(A).values()), reverse=True)[K:])))
from collections import *

N, K = list(map(int, input().split()))
print((sum(v for _, v in Counter(list(map(int, input().split()))).most_common()[K:])))

from collections import Counter

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print((sum(sorted(list(Counter(A).values()), reverse=True)[K:])))

-from collections import * +from collections import Counter -N, K = list(map(int, input().split())) -print((sum(v for _, v in Counter(list(map(int, input().split()))).most_common()[K:]))) +N, K = [int(i) for i in input().split()] +A = [int(i) for i in input().split()] +print((sum(sorted(list(Counter(A).values()), reverse=True)[K:])))