#include<bits/stdc++.h>

using namespace std;

#define endl '\n'

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int N, W;
    cin >> N >> W;

    vector<int> v;
    vector<int> w;

    for (int i = 0; i < N; ++i){
    	int vi, wi, mi;
    	cin >> vi >> wi >> mi;
    	int p = 1;
    	while (p < mi){
    		v.push_back(vi * p);
    		w.push_back(wi * p);
    		mi -= p;
    		p = p << 1;
    	}
    	v.push_back(vi * mi);
		w.push_back(wi * mi);
    }

    N = v.size();
    vector<int> dp(W + 1);

    for (int i = N - 1; i >= 0; --i){
    	vector<int> tmp(W + 1);
    	for (int j = 0; j <= W; ++j){
    		tmp[j] = dp[j];
    		if (j >= w[i])
    			tmp[j] = max(tmp[j], dp[j - w[i]] + v[i]);
    	}
    	dp.swap(tmp);
    }

    cout << dp[W] << endl;
}

