N,M = map(int,input().split()) C = sorted([0] + [int(a) for a in input().split()]) for i in range(N): C[i+1] += C[i] for i in range(N,-1,-1): if C[i] <= M: print(i) exit()