#include<bits/stdc++.h>
using namespace std;
int v[105], w[105], s[105];
int f[105][105];
int main(){
int N, V;
cin>>N>>V;
for(int i = 1; i <= N; i++) cin>>v[i]>>w[i]>>s[i];
for(int i = 1; i <= N; i++){
for(int j = 1; j <= V; j++){
int num = min(j/v[i], s[i]);
for(int k = 0; k <= num; k++){
f[i][j] = max(f[i][j], f[i-1][j-k*v[i]] + k*w[i]);
}
}
}
cout<<f[N][V]<<endl;
return 0;
}