'use strict';

const main = (input) => {
    const l = input.split('\n');
    const l0 = l[0].split(' ');
    const N = parseInt(l0[0], 10);
    const x = parseInt(l0[1], 10);
    const l1 = l[1].split(' ');
    const a = l1.map((v) => parseInt(v, 10)).slice(0, N);
    const sa = a.sort();
    let n = 0;
    let i = 0;
    let k = x;
    while (i < N)  {
        if (k > sa[i]) {
            if (i == N - 1) {
                break;
            } else {
                n++;
                k -= sa[i];
            }
        } else if (k == sa[i]) {
            n++;
            k -= sa[i];
        } else {
            break;
        }
        i++;
    }
    console.log(n);
}

const isTest = false;

if (isTest) {
    main('3 70\n20 30 10');
    main('3 10\n20 30 10');
    main('4 1111\n1 10 100 1000');
    main('2 10\n20 20');
} else {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
}