import scala.io.StdIn
object Main extends App {
  val List(n,x) = StdIn.readLine().split(" ").map(_.toInt).toList
  val a = StdIn.readLine().split(" ").map(_.toInt).sorted
  val sumList = a.scan(0)(_+_).drop(1)
  println(if (a.take(sumList.takeWhile(_ <= x).length).sum == x || a.nonEmpty) sumList.length else 0.max(sumList.length - 1))
}
