import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, x = sc.nextInt()
    val kids = List.fill(n)(sc.nextInt()).sorted.scan(0)((a, b) => a + b)
    val a = math.max(kids.takeWhile(_ <= x).length - 1, 0)
    if (x == kids(a)) {
      println(a)
    } else {
      println(a - 1)
    }
  }

}
