import bisect
n, x = map(int, input().split())
*a, = sorted(map(int, input().split()))

res = [sum(a[:i+1]) for i in range(len(a))]
index = bisect.bisect_left(res, x)

if index == len(res):
    print(index-1)
elif index == 0:
    if res[index] == x:
        print(index+1)
    else:
        print(index)
else:
    print(index+1)
