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

if x < a[0]:
    print(0)
    exit()


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


if x <= 0:
    print(ans)
else:
    print(ans-1)
