from collections import Counter



n,k = list(map(int,input().split()))

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



cnt_lst = Counter(n_lst).most_common()[k:]

ans = 0

for x in cnt_lst:

    ans += x[1]

print(ans)

n,k = list(map(int,input().split()))

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

cnt_lst = [0 for _ in range(n+1)]



for x in n_lst:

    cnt_lst[x] += 1

cnt_lst.sort(reverse=True)

print((sum(cnt_lst[k:])))

from collections import Counter

n, k = list(map(int, input().split()))
n_lst = list(map(int, input().split()))
cnt_lst = Counter(n_lst).most_common()[k:]
ans = 0
for x in cnt_lst:
    ans += x[1]
print(ans)

n, k = list(map(int, input().split()))
n_lst = list(map(int, input().split()))
cnt_lst = [0 for _ in range(n + 1)]
for x in n_lst:
    cnt_lst[x] += 1
cnt_lst.sort(reverse=True)
print((sum(cnt_lst[k:])))

-from collections import Counter - -cnt_lst = Counter(n_lst).most_common()[k:] -ans = 0 -for x in cnt_lst: -    ans += x[1] -print(ans) +cnt_lst = [0 for _ in range(n + 1)] +for x in n_lst: +    cnt_lst[x] += 1 +cnt_lst.sort(reverse=True) +print((sum(cnt_lst[k:])))