xy=input().split()
n=int(xy[0])
x=int(xy[1])
l=input().split()
l.sort()
sum=0
i=0
while sum<x and i+1<=n:
    sum=sum+int(l[i])
    i=i+1
#    print(i,sum)
if sum>x:
    print(i-1)
elif sum<x:
    print(i-1)
else:
    print(i)