N,x=map(int,input().split())
a=list(map(int, input().split()))
a.sort()
m=0
i=0
if a[0]>x:
    print(0)
else:
    while m<=x and i<N:
        m += a[i]
        i +=1
    if i==N and m!=x:
        i -=1
        print(i)
    else:
        print(i)