N,x=map(int,input().split())
l=list(input().split())
for i in range(N):
    l[i]=int(l[i])
l.sort()
s=0
p=0
for i in range(N):
     s+=l[i]
     if s>x:
         break
     else:
         p+=1
print(p)
