n, x = map(int, input().split())
a = list(map(int, input().split()))
a_asc = sorted(a)
ans = 0
val = 0
for i in range(n):
    val += a_asc[i]
    if val <= x:
        ans += 1
    else:
        val -= a_asc[i]
print(ans - 1 if val < x else ans)