from numpy import *

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

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