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

a = sorted(a)
ans = 0

for i in range(N):
    if a[i] <= x:
        x -= a[i]
        ans += 1

if x > 0 and ans > 0:
    ans -= 1
    print(ans)
elif x == 0:
    print(ans)
else:
    print(0)
