import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val N, W = sc.nextInt
    val dp = Array.fill[Int](W + 1)(0)
    for (_ <- 0 until N) {
      val v, w, m = sc.nextInt
      for (_ <- 0 until m) {
        for (i <- 0 to W - w) {
          val x = W - i
          val y = W - i - w
          dp(x) = math.max(dp(x), dp(y) + v)
        }
      }
    }
    println(dp(W))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}