N, x = map(int, input().split())
cage = sorted([int(i) for i in input().split()])
cage = sorted(cage)
ans=0

for i in range(N):
    n = cage[i]
    if x>=n:
        x = x - n
        ans += 1
    else:
        break

if cage[0]>x:
    ans=0
if x != 0:
    ans -= 1
print(ans)