n, x, *a = map(int, open(0).read().split())
a.sort()
cnt = 0
for i in range(n):
    if x >= a[i]:
        x -= a[i]
        cnt += 1
        print(a,x,cnt)
    else:
        break
if x > 0:
    cnt -= 1
print(max(cnt,0))
    