n, x = map(int, input().split())
l = list(map(int, (input().split())))
l.sort()
count = 0
total = x
for i in range(len(l)):
    if total - l[i] < 0:
        break
    total -= l[i]
    count += 1

if (total == 0) | (total == x):
    print(count)
else:
    print(count-1)