def solve(n, x, a):
    ans = 0
    for v in sorted(a):
        if v <= x:
            ans += 1
            x -= v
    return ans if (x <= 0) else ans - 1

n, x = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, x, a))