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