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

print(bl(d,x))