from collections import Counter



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

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



print((sum(v for _, v in Counter(A).most_common()[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(v for _, v in Counter(A).most_common()[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 +from collections import * -N, K = [int(i) for i in input().split()] -A = [int(i) for i in input().split()] -print((sum(v for _, v in Counter(A).most_common()[K:]))) +N, K = list(map(int, input().split())) +print((sum(v for _, v in Counter(list(map(int, input().split()))).most_common()[K:])))