N = int(input())
x = int(input())
y=x
cage = []
for i in range(N):
    nu = int(input())
    cage.append(nu)
ans=0
for i in range(N):
    ind = cage.index(min(cage))
    if(min(cage) > x):
        break
    x = x - min(cage)
    cage[ind] = y
    ans += 1
if x>0:
    ans = ans - 1
print(ans)