"use strict";
const main = arg => {
  let N = arg.split("\n")[0].split(" ")[0]*1;
  let x = arg.split("\n")[0].split(" ")[1]*1;
  let a = arg.split("\n")[1].split(" ");
  let count = 0;
  a = a.sort((a, b) => a - b)
  for(let i = 0; i < N; i++){
	if(x >= a[i]){
		x -= a[i]
      	count++;
    } else {
    	break;
    }
  }
  if(x > 0 && count!= 0){
  	count--;
  }
  
  console.log(count);
}

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