# -*- coding: utf-8 -*-
"""
A - Candy Distribution Again
https://atcoder.jp/contests/agc027/tasks/agc027_a

"""
import sys


def solve(N, x, A):
    ans = 0
    for a in A:
        if x >= a:
            ans += 1
            x -= a
    return ans if x == 0 else max(ans-1, 0)


def main(args):
    N, x = map(int, input().split())
    A = sorted([int(a) for a in input().split()])
    ans = solve(N, x, A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
