function candyDistributionAgain(N, x, a) {
  a.sort(function(a,b) {
    return a - b;
  });
  
  var satisfaction = 0; //  ＼（｀д´）ゝ
  for ( var i = 0; i < a.length; i++ ) {
    x -= a[i];
    if (x >= 0) {
        satisfaction++;
    }
  }
  
  if (x > 0) {
      satisfaction--;
  }
  return satisfaction;
}

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(candyDistributionAgain(N, x, a));
}

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