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