import heapq N,M = map(int,raw_input().split()) C = map(int, raw_input().split()) C.sort() for x in range(len(C)): if (C[x] - M >= 0): C[x] -= M break else: M -= C[x] C[x] = 0 print C.count(0)