from itertools import accumulate
import bisect
N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = list(accumulate(a))
ans = bisect.bisect_left(c, x)
if not ans:
  print(ans)
else:
  print(ans if ans != N else ans - 1)