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

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