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


int main(){
int n,W;
cin>>n>>W;
vector<int> dp(W+1,0);
vector<int> v(n+1),w(n+1),m(n+1);
for(int i=0;i<n;i++)cin>>v[i]>>w[i]>>m[i];

for(int i=0;i<n;i++){
	for(int k=0;m[i]>0;k++){
	int tmp = min(m[i],(int)1<<k);
	for(int j=W-tmp*w[i];j>=0;j--)	dp[j+tmp*w[i]]=max(dp[j+tmp*w[i]],dp[j]+tmp*v[i]);
	m[i]-=tmp;
	}	
}

int ans=0;
	for(int i=0;i<=W;i++)ans = max(ans,dp[i]);
cout<<ans<<endl;
return 0;
}

