from heapq import heapify, heappop, heappush N, M, *C = map(int, open(0).read().split()) heapify(C) while M != 0: if len(C) == 0: print(N) break t = heappop(C) u = min((C[0] - t) + 1, t, M) t -= u M -= u if t != 0: heappush(C, t) else: print(N - len(C))