from itertools import combinations

N, x = input().split()
a = input().split()

N = int(N)
x = int(x)
a = list(sorted((map(int, a))))

if x < min(a) or x == 0:
    print(0)
elif x >= sum(a):
    print(N)
else:
    for i in range(N-1, 0, -1):
        m = sum(a[:i])
        #m = min(map(sum, combinations(a, i)))
        if x >= m:
            print(i)
            break
