n, x = map(int, input().split())
res = 0
dat = list(map(int, input().split()))
dat.sort()
for i in range(n):
    if x >= dat[i]:
        res += 1
        x -= dat[i]
if x > 0 and res != 0:
    res -= 1
print(res)