N,X = map(int,input().split())
src = list(map(int,input().split()))
src.sort()

x = 0
ans = 0
for a in src:
    if x+a > X: break
    ans += 1
    x += a
if x != X and ans > 0:
    ans -= 1
print(ans)