#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
const int INF = pow(2, 31) - 1;
int main(){
    int n, W;
    cin >> n >> W;
    vector<int> dp(W+1, 0);
    rep(i,n){
        int v, w, m;
        cin >> v >> w >> m;
        for(int k = 0; m > 0; k++){
            int num = min(m, 1<<k);
            m -= num;
            for(int j = W; j >= w*num; j--)dp[j] = max(dp[j], dp[j - w*num] + v*num);
            //cout << "num = " << num << endl;
            //rep(j,W+1)cout << dp[j] << ((j < W)? " " : "\n");
        }
    }

    vector<int>::iterator it = max_element(dp.begin(), dp.end());
    cout << *it << endl;
    return 0;
}
