from collections import Counter N, K = map(int, input().split()) A = list(map(int, input().split())) items = [k for k in Counter(A).values()] items.sort(reverse = True) ans = 0 cnt = 0 i = 0 while cnt < K: ans += 1 cnt += items[i] i += 1 print(ans)