process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var nx = lines[0].split(' ');
 var n = Number(nx[0]);
 var x = Number(nx[1]);
 var x_p = x;
 var i = 0;
 var count = 0;

 var a = lines[1].split(' ');
 a = a.map(function(str) { return Number(str)});
 var sum = a.reduce(function(a, x){return a + x;});

 

 a = a.sort((a, b)=> a - b);
 while(true){
   if(a[i] > x){
     break;
   }
   if(i+1 == n){
     if(a[n] == x){
       count++;
     }else{
       break;
     }
   }
   x = x - a[i];
   count++;
   i++;
   
 }
  
  if(sum == x_p){
   count = n;
 }
  console.log(count);

});