function candy_distribution_again(N, x, a) {
    a.sort(
        function(a, b) {
            return a - b;
        }
    );
    
    for (var i = 0; i < N; i++) {
        x -= a[i];
    
        if (x == 0) return i + 1;
        if (x < 0) return i;
        if (!a[i + 1]) return i;
        if (x < a[i + 1]) return i + 1;
    }
}
function main(input) {
    var input = input.split("\n");
    var Nx = input[0].split(" ");
    var a = input[1].split(" ");
    var N = Nx[0];
    var x = Nx[1];
    console.log(candy_distribution_again(N, x, a));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));