N, x = map(int, input().split())
A = sorted(list(map(int, input().split())))
S = 0
ans = 0
for a in A:
    if S + a > x:
        break
    else:
        S += a
        ans += 1

print(ans - (S != x))
