#include <iostream>
using namespace std;
const int N = 1010;
int n, V, M;
struct node{
int v, w, m;
}a[N];
int dp[110][110];
int main(){
cin >> n >> V >> M;
for (int i = 1; i <= n; i ++ ){
cin >> a[i].v >> a[i].m >> a[i].w;
}
for(int i = 1; i <= n; i++){
for(int j = V; j >= a[i].v; j--){
for(int k = M; k >= a[i].m; k--){
dp[j][k] = max(dp[j][k], dp[j-a[i].v][k-a[i].m]+a[i].w);
}
}
}
cout << dp[V][M];
return 0;
}