//注意:这不是多重背包!
include [HTML_REMOVED]
using namespace std;
const int N = 1005;
int w[N], v[N], s[N], f[N][N], n, m, x, i, j, k;
int main()
{
cin >> n >> x >> m;
for(int i = 1; i <= n; ++i)
{
cin >> w[i] >> v[i] >> s[i];
for(j = x; j >= 0; --j)
for(k = m; k >= 0; --k)
if (j >= w[i] && k >= v[i]) f[j][k] = max(f[j][k], f[j - w[i]][k - v[i]] + s[i]);
}
cout << f[x][m] << endl;
return 0;
}