
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 memo: Map[(Int, Int), Int] = Map.empty

  def exec(num: Int, nowSize: Int): Int = {
    memo.get((num, nowSize)) match {
      case Some(cnt) => cnt
      case None =>

        if (num >= data.length - 1 && nowSize == data(num))
          return 1
        if (num >= data.length - 1 && nowSize != data(num))
          return 0


        if (nowSize >= data(num)) {
          val n = List(exec(num + 1, nowSize - data(num)) + 1, exec(num + 1, nowSize)).max
          memo = memo + ((num, nowSize) -> n)
          return n
        }

        memo = memo + ((num, nowSize) -> exec(num + 1, nowSize))
        memo((num, nowSize))
    }
  }

  println(exec(0, x))
}
