object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN, datX) = readLine.split(" ").map(_.toInt)
    val datA = readLine.split(" ").map(_.toInt)
    val datB = datA.toList.sorted

    def distCandy(result: Int, candy: Int, child: List[Int]): Int = (candy, child) match {
      case (n, _) if(n == 0) => result
      case (_, Nil) => result - 1 // 全員に配ってまだ余った時に最後に押し付ける処理
      case (n, m :: _) if (n < m) => result
      case (n, m :: tail) if (n >= m) => distCandy(result + 1, n - m, tail)
    }
    val ans = distCandy(0, datX, datB)

    println(ans)
  }
}
