class Problem0156: def solve(this): n,m = map(int, input().split()) c = list(map(int, input().split())) c.sort() cnt = 0 idx = 0 while cnt <= m: cnt += c[idx] if cnt > m: break else: idx += 1 if idx >= n: break print(idx) if __name__ == "__main__": problem = Problem0156() problem.solve()