include[HTML_REMOVED]
using namespace std;
const int N = 1005;
int w[N], v[N], s[N], f[N], n, m;
int main()
{
cin >> n >> m;
for(int i = 1; i <= n; i)
cin >> w[i] >> v[i] >> s[i];
for(int i = 1; i <= n; i)
for(int j = m; j >= 0; –j)
for(int k = 1; k <= s[i]; ++k)
if(j >= k * w[i])
f[j] = max(f[j], f[j - k * w[i]] + k * v[i]);
cout << f[m] << endl;
return 0;
}