s = require("fs").readFileSync("/dev/stdin", "utf8");
var s = s.split("\n");
var n = parseInt(s[0].split(" ")[0], 10);
var x = parseInt(s[0].split(" ")[1], 10);
var a = s[1].split(" ").map(e => parseInt(e, 10)).sort();
var cnt = 0;
for (var i = 0; i < n; i++) {
  if (x >= a[i]) {
    x -= a[i];
    cnt++;
  } else {
    break;
  }
}
if (x > 0 && cnt >= n) {
  cnt--;
}
console.log(cnt);