function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0].split(' ')[0], 10);
  let x = parseInt(args[0].split(' ')[1], 10);
  let ary = args[1].split(' ').map(n => parseInt(n, 10)).sort();
  let ans = 0;
  
  for (let i = 0; i < N; i++) {
  	if (x >= ary[i]) {
      ans++;
      x -= ary[i];
    }
  }
  
  console.log(ans);
}

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