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