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

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