object Main extends App {
  val Array(n, x) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val data = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  var now = x
  var count = 0
  data.sorted.foreach { i =>
    if (i <= now) {
      now -= i
      count += 1
    }
  }
  if (now != 0) {
    println(List(count - 1, 0).max)
  } else {
    println(count)

  }
}
