
object Main extends App {
  val Array(n, x) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val data = scala.io.StdIn.readLine.split(" ").map(_.toInt).sorted.reverse

  if (data.sum == x) {
    println(n)
  } else {
    if (x > data.sum) {
      println(n - 1)
    } else {
      var nowSize = data.sum
      var cnt = n
      data.foreach { i =>
        if (x < nowSize) {
          nowSize -= i
          cnt -= 1
        }
      }
      println(cnt)
    }
  }
}
