#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(N: int, x: int, a: "List[int]"):
    a.sort()
    res = 0
    xx = x
    for i in range(N):
        if x >= a[i]:
            res += 1
            x -= a[i]
    if x > 0 and sum(a) <= xx:
        print(res - 1)
    elif x > 0 and sum(a) > xx:
        print(0)
    else:
        print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, x, a)

if __name__ == '__main__':
    main()
