object Main extends App {
  import scala.annotation.tailrec
  
  @tailrec
  def solve(a:List[Int],x:Int,ans:Int):Int = {
    a match {
      case h::Nil if x > 0 => if (h==x) ans+1 else ans
      case h::t if h <= x => solve(t,x-h,ans+1)
      case _ => ans
    }
  }
  
  val Array(n,x) = readLine.split(" ").map{_.toInt}
  val a = readLine.split(" ").map{_.toInt}.sorted.toList
  
  println(solve(a,x,0))
}