import bisect

N, x = map(int, input().split())
A = list(map(int, input().split()))
S = [0] * (N + 1)
A.sort()

for i, a in enumerate(A):
    S[i + 1] = S[i] + a

if S[-1] > x:
    print(N - 1)
elif S[-1] == x:
    print(N)
else:
    print(bisect.bisect_right(S, x))

