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