n,x=map(int,input().split())
a=sorted([int(i)for i in input().split()])
isHappy=[False for i in range(n)]
res=0
for i in range(n):
    if x>=a[i]:
        isHappy[i]=True
        x-=a[i]
    else:
        break
res=isHappy.count(True)
if x != 0:res-=1
print(max(0,res))