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