
object Main extends App {
  import scala.io.StdIn._
  val Array(n, x) = readLine.trim.split(' ').map(_.toLong)
  val nums = readLine.trim.split(' ').map(_.toLong)
  val max = nums.max
  val sum = nums.sum
  if (sum < x){
    println(n - 1)
  }else if (sum == x){
    println(n)
  }else {
    var count = 0
    var rest = x
    for (a ← nums){
      if (rest - a >= 0) {
        count += 1
        rest -= a
      }
    }
    println(count)
  }
  implicit class ScopedFunc[T](val value: T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[A](func: T ⇒ A): A = {
      func(value)
    }
  }
}
