import numpy

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

ans = len(a_sum)
for i in range(len(a_sum)):
    if a_sum[i] > x:
        ans = i
        break

print(ans)
