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

ans = 0

A.sort()

for i in range(N):
    if X > A[i]:
        if i == N - 1:
            break
        else:
            ans += 1
            X -= A[i]
    elif X == A[i]:
        ans += 1
        X -= A[i]
        break
    else:
        break

print(ans)
