nx = map(int, raw_input().split())
ais= map(int, raw_input().split())
ailen=len(ais)
ai=sorted(ais)
counti=0
ans=0
for i in ai:
    counti=counti+1
    nx[1]=nx[1]-i
    if nx[1]>=0:
        ans=ans+1
    else:
        if nx[1]<0:
            nx[1]=nx[1]+i
        break
if ailen==counti and nx[1]>0:
    ans=ans-1
print ans
