N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
if sum(a) > x:
    num = a[0]
    i = 0
    while num <= x:
        num += a[i]
        i += 1
    print(i)
elif sum(a) == x:
    print(N)
else:
    print(N-1)