import numpy

N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
a_sum = numpy.cumsum(a)
ans = numpy.sum(a_sum <= x)

if ans > 1 and a_sum[ans-1] != x:
    ans -= 1

print(ans)
