#include <iostream>
using namespace std;
const int N = 10010;
int n, m;
int f[N], w[N], v[N];
int main()
{
cin >> n >> m;
int cnt = 1;
for(int i = 1; i <= n; i++)
{
int v, w, s;
cin >> v >> w >> s;
for(int j = m; j >= 0; j--)
for(int k = 1; k <= s && k * v <= j; k ++) // 遍历可选件数
f[j] = max(f[j], f[j - k * v] + k * w);
}
cout << f[m];
return 0;
}