#include <iostream>
#include <cstdio>
using namespace std;
const int N = 1010, M = 110;
int f[M][M];
int v[N], w[N], value[N];
int volume, weight;
int n;
int main()
{
cin >> n >> volume >> weight;
for (int i = 0; i < n; i ++) scanf("%d%d%d", v + i, w + i, value + i);
for (int i = 0; i < n; i ++)
for (int j = volume; j >= v[i]; j --)
for (int k = weight; k >= w[i]; k --)
f[j][k] = max(f[j][k], f[j - v[i]][k - w[i]] + value[i]);
cout << f[volume][weight] << endl;
return 0;
}