from bisect import bisect_left
from itertools import accumulate


N, x = map(int, input().split())
a = list(accumulate(sorted(map(int, input().split()))))
if x in a:
    print(bisect_left(a, x) + 1)
else:
    print(max(0, bisect_left(a, x) - 1))