
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())

n,x=mii()
a=list(mii())


if sum(a)==x:
    print(n)
else:
    # do a prefix
    ans=0
    a.sort()
    for i in range(n):
        if x>=a[i]:
            x-=a[i]
            ans+=1
    print(ans)
