
object Main extends App {
  val sc = new java.util.Scanner(System.in) 
  var n = sc.nextInt()
  var x = sc.nextInt()
  sc.useDelimiter("\n")
  val a = sc.next().split(" ").map(_.toInt).toList.sorted
  var i = 0
  var ans = 0
  for (i <- 0 until n) {
    if (a(i) <= x) {
      ans += 1
      x -= a(i)
    }
  }
  if (ans != 0 && x != 0) ans -= 1
  println(ans)
}