N,x = map(int,input().split())

a = list(map(int,input().split()))

a.sort()
cnt=0

for i in range(N):
    if x -a[i] >= 0:
        cnt+=1
        x = x-a[i]

if x >0:
    if cnt == 0:
        cnt = 0
    else:
        cnt = cnt -1
        
print(cnt)