object Main extends App{
  import scala.io.StdIn.readLine
  
  val x = readLine.split(" ")(1).toInt
  val children = readLine.split(" ").map(_.toInt).sortWith(_ > _)
  
  val maxpoint = (1 to children.length).map(a =>children.take(a).sum).indexWhere(_ > x)
  
  if(maxpoint == -1){
    if(x == children.sum){println(children.length.toString)}
    else {println((children.length - 1).toString)}
  }
  else println((maxpoint + 1).toString)
  
   
}
