def solve(n, x, A):
    A.sort()
    count = 0
    for a in A:
        if a <= x:
            x -= a
            count += 1
        else:
            break
    return count

_n, _x = list(map(int, input().split()))
_A = list(map(int, input().split()))
print(solve(_n, _x, _A))
