n,x=map(int,input().split())
l=sorted(list(map(int,input().split())))
d=[]
now=0
for i in l:
    now+=i;d.append(now)
from bisect import bisect_left as bl,bisect_right as br

print(br(d,x)-1+(sum(l)==x))