n,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
ans = 0
if a[0] <= x: 
    for i in range(n):
        if a[i] < x:
            x -= a[i]
        ans += 1

else:
    print(0)
    exit()


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

    


