n, x = map(int, input().split())
A = sorted(list(map(int, input().split())))

ans = 0
for a in A:
    if x - a >= 0:
        x -= a
        ans += 1
    else:
        break
if x != 0 and ans > 0:
    ans -= 1
print(ans)
