function Main(input){
  input=input.split('\n');
  input[0]=input[0].split(' ');
  var N=parseInt(input[0][0]);
  var candy=parseInt(input[0][1]);
  input[1]=input[1].split(' ');
  var x_=[];
  (function(){
    var subArray=[];
    for(var i=0;i<N;i++){
      subArray=x_.concat();
      var insertee=parseInt(input[1][i]);
      var m=subArray.length/2;
      var counter=0;
      while(subArray.length>0){
        if((2*m)%2===0){
          if(insertee<subArray[m]){
            subArray.splice(m);
          }else{
            subArray.splice(0,m+1);
            counter += (m+1);
          }
        }
        if((2*m)%2===1){
          if(insertee<subArray[m-1/2]){
            subArray.splice(m-1/2);
          }else{
            subArray.splice(0,m+1/2);
            counter += (m+1/2);
          }
        }
        m=subArray.length/2;
      }
    x_.splice(counter,0,insertee);
   }
  })();
  var counter=0;
  while(x_[counter]&&!(candy<0)){
    if(!(candy<x_[counter])){
      candy -= x_[counter];
      counter++;
      continue;
    }
    break;
  }
  console.log(counter);
}

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