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.nextLong()).sorted.scan(0)((a, b) => a + b)
    val sum = kids(n)
    val a = kids.takeWhile(_ <= x).length

    if (sum == x) println(n)
    else
      a match {
        case 1                     => println(0)
        case m if kids(m - 1) == x => println(m - 1)
        case m if m == kids.length => println(m - 2)
        case m                     => println(m - 1)
      }
  }
}
