iN,iX = [int(x) for x in input().split()]
aL = [int(x) for x in input().split()]
aL.sort()
iCounter = 0
for iE in aL:
    if iX >= iE:
        iX -= iE
        iCounter += 1
    else:
        break
#余ってる
if iX > 0 and iCounter > 0:
    iCounter -= 1
print(iCounter)
