N,X = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

b = []
for i in range(N):
    b.append(0)
    
c = 0

d = []
for i in range(N):
    d.append(0)


for i in range(N):
    for j in range(i+1):
        d[i] += a[j]
        b[i] = d[i]
for i in range(N):
    if b[i] <= X:
        c += 1
print(c)