#include <bits/stdc++.h>
using namespace std;

int knapsack(vector<int> &v, vector<int> &w, vector<int> &m, int W) {
    vector<int> dp(W + 1, 0);
    for (int i = 0; i < v.size(); ++i) {
        int num = m[i];
        for (int k = 1; num > 0; k <<= 1) {
            int mul = min(k, num);
            for (int j = W; j >= w[i] * mul; --j) {
                dp[j] = max(dp[j], dp[j - w[i] * mul] + v[i] * mul);
            }
            num -= mul;
        }
    }
    return dp[W];
}

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N), m(N);
    for (int i = 0; i < N; ++i) {
        cin >> v[i] >> w[i] >> m[i];
    }
    cout << knapsack(v, w, m, W) << endl;
}
