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