n,x=map(int,input().split())
a=sorted([int(i)for i in input().split()])
res=0
if sum(a)==x:
    res=n
else:
    for i in range(n+1):
        if sum(a[:i])==x:res=len(a[:i])
        elif sum(a[:i])<x:res=len(a[:i])-1
print(max(0,res))