function Main(input) {
  var inputs = input.split("\n");
  var n = parseInt(inputs[0].split(" ")[0], 10);
  var x = parseInt(inputs[0].split(" ")[1], 10);
  var a = inputs[1].split(" ").map(e => parseInt(e, 10)).sort();
  var cnt = 0;
  for (var i = 0; i < n; i++) {
    x -= a[i];
    if (x == 0) {
      cnt++;
      break;
    } else if (x < 0 && i + 1 != n) {
      cnt++;
    } else {
      break;
    }
  }
  console.log(cnt);
}

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