N, X = map(int, input().split())
A = [int(c) for c in input().split()]
A.sort()
ans = 0
i = 0
while i < len(A):
    if A[i] <= X:
        ans += 1
        X -= A[i]
    else:
        break
    i += 1
if X > 0:
    ans = max(0, ans - 1)
print(ans)
