import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit =
    solve(new Scanner(System.in)) match {
      case s: String if s.length > 0 => println(s)
      case a: Seq[Any] if a.nonEmpty => a.foreach(println)
      case Nil => Unit
      case _: Unit => Unit
      case o => println(o)
    }

  def solve(in: String): Any = solve(new Scanner(in))

  def solve(sc: Scanner): Any = {
    val N = sc.nextInt
    var x = sc.nextInt
    val a = Array.fill(N)(sc.nextInt)

    var r = 0
    a.sorted.foreach { a =>
      if (a <= x) r += 1
      x -= a
    }
    if (x > 0) r -= 1
    r
  }
}
