import itertools

N, x = map(int, input().split())
a = list(map(int, input().split()))

if sum(a) == x:
    print(N)
    exit()

for i in range(N - 1, 0, -1):
    for element in itertools.combinations(a, i):
        if sum(element) <= x:
            print(i)
            exit()

print(0)
exit()
