#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e4 +10;
int n, m;
int a[N], b[N];
int dp[N], v, w, s;
int t;
int main()
{
cin >> n >> m;
while(n -- )
{
cin >> v >> w >> s;
while(s -- )
{
a[++ t] = v;
b[t] = w;
}
}
for(int i = 1; i <= t; i ++ )
for(int j = m; j >= a[i]; j -- )
dp[j] = max(dp[j - a[i]] + b[i], dp[j]);
cout << dp[m] << endl;
return 0;
}