import scala.math._ object Main { def main(args: Array[String]) = { val sc = new java.util.Scanner(System.in) val n, m = sc.nextInt val xs = (1 to n).map { _ => sc.nextInt }.toList.sorted def rec(m: Int, xs: List[Int]): Int = xs match { case Nil => 0 case (y :: ys) => if (m < y) 0 else 1 + rec(m - y, ys) } println(rec(m, xs)) } }