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