"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const N = input[0].trim().split(' ').map(Number)[0];
  let X = input[0].trim().split(' ').map(Number)[1];
  const a = input[1].trim().split(' ').map(Number).sort((a,b) => a-b);

  let ret = 0;
  for(let i=0; i<N; i++){
    if(i === N-1){
      if(a[i] === X) ret += 1;
    }else if(X >= a[i]){
      X -= a[i];
      ret += 1;
    } else {
      break;
    }
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));