#include <bits/stdc++.h>
#define bug cout << "***************" << endl
#define int long long
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
using namespace std;
constexpr int N = 1e3 + 10, INF = 2e9;
int a[N], b[N], c[N];
int dp[N][N];
void solve()
{
int n, x;
cin >> n >> x;
for (int i = 1; i <= n; i++)
{
cin >> a[i] >> b[i] >> c[i];
}
int res = 0;
for (int i = 1; i <= n; i++)
{
for (int j = 0; j <= x; j++) // 背包问题一定要从0开始;!!!!!!!!!!!!!!
{
dp[i][j] = dp[i - 1][j] + a[i]; // 不用药
if (c[i] <= j) // 可以用药;
{
dp[i][j] = max(dp[i][j], dp[i - 1][j - c[i]] + b[i]);
}
res = max(res, dp[i][j]);
}
}
cout << res * 5 << endl;
}
signed main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T = 1;
// cin>>T;
while (T--)
{
solve();
}
return 0;
}