n,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cnt = 0
tank = 0
for i in range(n):
    if tank+A[i] <= x:
        tank += A[i]
        cnt += 1
    else:
        break
print(cnt if tank==x else max(cnt-1, 0))