n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
print(a)
cnt=0
for i in range(n):
    if (x-a[i]>=0):
        cnt=cnt+1
    x=x-a[i]
    #print(x)
if x <= 0:
    print(cnt)
else:
    print(cnt-1)
