# AGC027A - Candy Distribution Again
# greedy algorithm
from itertools import accumulate


def main():
    # maximize the number of proper distribution -> begin with small values
    n, x = tuple(map(int, input().rstrip().split()))
    A = sorted(map(int, input().rstrip().split()))
    ans = sum(i <= x for i in accumulate(A))
    print(ans)


if __name__ == "__main__":
    main()