include [HTML_REMOVED]
using namespace std;
const int M = 2e3 + 10;
int dp[M][M];
int v[M], w[M], s[M];
int N, V;
int main()
{
cin >> N >> V;
int t = 0;
for (int i = 1; i <= N; i++)
{
int a, b, c;
cin >> a >> b >> c;
for(int j = 1; j <= c; j ++)
{
v[++ t] = a;
w[t] = b;
}
}
for (int i = 1; i <= t; i++)
{
for (int j = V; j >= v[i]; j--)
{
if (v[i] > j)
dp[i][j] = dp[i - 1][j];
else
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
}
}
cout << dp[t][V];
}