from itertools import accumulate
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = list(accumulate(a))
ans = sum([1 for i in c if i <= x])
if not ans:
  print(ans)
else:
  print(ans if x in list(c) else ans - 1)