#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int R = 1010;
int f[R][R];
int N, V, M;
int main()
{
cin >> N >> V >> M;
for(int i = 0; i < N; i++)
{
int v, m, w;
cin >> v >> m >> w;
for(int j = V; j >= v; j--)
for(int k = M; k >= m; k--)
f[j][k] = max(f[j][k], f[j-v][k-m] + w);
}
cout << f[V][M] << endl;
return 0;
}