from numpy import *
# import sys

N,x=map(int,input().split())
a=zeros(N)
a=[int(i) for i in input().split()]

a.sort()
count=0
for i in range(N):
    if(x-a[i]>=0):
        count+=1
        x-=a[i]
    else:
        break
print(count)