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;
  var i = 0;
  while(true) {
    if (x > a[i]) {
      x -= a[i];
      cnt++;
      if (i === n - 1) {
        cnt--;
        break;
      }
    } else if (x === a[i]) {
      cnt++;
      break;
    } else {
      break;
    }
    i++;
  }
  console.log(cnt);
}

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