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


def main():
    n, x = tuple(map(int, input().rstrip().split()))
    A = sorted(map(int, input().rstrip().split()))
    ac = list(accumulate(A))
    ans = bisect(ac, x)
    flg = x in ac
    print(ans if flg else max(0, ans - 1))


if __name__ == "__main__":
    main()