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