n, x = map(int, input().split())
a=list(map(int, input().split()))
a.sort()
count=0
sum_a=0
for i in range(n-1):
    sum_a+=a[i]
    if x>=sum_a:
        count+=1
else:
    if x>sum_a and i==n-1:
        count+=1
    else: print(count)