"use strict";
const s = require('fs').readFileSync('/dev/stdin', 'utf8');
let n = s.split("\n")[0].split(" ")[0]*1;
let x = s.split("\n")[0].split(" ")[1]*1;
let a = s.split("\n")[1].split(" ").sort((a, b) => a - b);
let cnt = 0;
for(let i = 0; i < n; i++){
  if(x >= a[i]) {
    x -= a[i]
    cnt++;
  } else {
    break;
  }
}
if (x > 0 && cnt >= n) {
  cnt--;
}
console.log(cnt);