object DPL_1_B {

  def main(args: Array[String]): Unit = {
    val (num, limit) = {
      val nw = io.StdIn.readLine().split(" ").map(_.toInt)
      (nw(0), nw(1))
    }
    val items = (for (_ <- 0 until num) yield io.StdIn.readLine())
      .map { str =>
        val vw = str.split(" ").map(_.toInt)
        (vw(0), vw(1))
      }

    val dp = Array.ofDim[Int](num + 1, limit + 1)
    items.zipWithIndex.foreach { case ((v, w), i) =>
      for (l <- 1 to limit) {
        if (w <= l) {
          dp(i + 1)(l) = Math.max(dp(i)(l), dp(i)(l - w) + v)
        } else {
          dp(i + 1)(l) = dp(i)(l)
        }
      }
    }

    println(dp(num)(limit))
  }

}