'use strict';

function Main(input) {
  const N = Number(input.split('\n')[0].split(' ')[0]);
  let x = Number(input.split('\n')[0].split(' ')[1]);
  let alist = input.split('\n')[1].split(' ').map(num => Number(num));
  alist.sort((a,b) => a < b ? -1 : 1);
  let aPointer = 0;

  while(aPointer < N) {
    if(x >= alist[aPointer]) {
      x -= alist[aPointer];
      aPointer++;
    } else {
      break;
    }
  }

  console.log(aPointer);

};

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