
object Main extends App {


  val Array(n, x) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val data = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  def exec(num: Int, nowSize: Int): Int = {
    if (num >= data.length - 1 && nowSize == data(num))
      return 1
    if (num >= data.length - 1 && nowSize != data(num))
      return 0


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

    exec(num + 1, nowSize)
  }

  println(exec(0, x))
}
