var Main = function(Input){
  var Lines = Input.split('\n');
  var Props = Lines[0].split(' ');
  var Children = Lines[1].split(' ').sort();

  var ChildrenNums = Number(Props[0]);
  var Candies = Number(Props[1]);

  // 数値に変換
  Children = Children.map(function (element){return Number(element);});

  var Result = 0;
  for(var i = 0;i<ChildrenNums;++i){
    Candies -= Children[i];

    // 最後の子供の場合
    if(i + 1 == ChildrenNums){
      if(Candies == 0){
        ++Result;
      }
      break;
    }
    
    if(Candies >= 0){
      ++Result;
    } else {
      break;
    }
  }
  console.log(Result);
}

Main(require("fs").readFileSync(__dirname+'/in.txt', "utf8"));
