#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;

int main(){
  ll n, W;
  cin >> n >> W;
  ll v[n], w[n], m[n];
  rep(i,n) cin >> v[i] >> w[i] >> m[i];
  vector<ll> vp, wp;
  rep(i,n) {
    ll cur = 1;
    while(m[i] > 0) {
      vp.push_back(v[i]*min(cur,m[i]));
      wp.push_back(w[i]*min(cur,m[i]));
      m[i] -= cur;
      cur *= 2;
    }
  }
  int l = vp.size();
  vector<vector<ll>> dp(l+1,vector<ll>(W+1));
  rep(i,l) {
    rep(j,W+1) {
      if(j > 0) dp[i+1][j] = max({dp[i+1][j],dp[i][j],dp[i+1][j-1]});
      if(j-wp[i] >= 0) dp[i+1][j] = max(dp[i+1][j],dp[i][j-wp[i]]+vp[i]);
    }
  }
  cout << dp[l][W] << endl;
  return 0;
}
