import bisect
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
for i in range(1,n):
    a[i] += a[i-1]
i = bisect.bisect_left(a,x)+1
if i==1 and a[0] > x : i=0
if i==n+1 and a[n-1] < x: i-=2
print(i)