import java.util.*;
public class Main {
static final int N = 1010, M = 110;
static int[][][] f = new int[N][M][M];
static int[] v = new int[N], m = new int[N], w = new int[N];
static int n, V, M2;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] str = sc.nextLine().split(" ");
n = Integer.parseInt(str[0]);
V = Integer.parseInt(str[1]);
M2 = Integer.parseInt(str[2]);
for (int i = 1; i <= n; i++) {
str = sc.nextLine().split(" ");
v[i] = Integer.parseInt(str[0]);
m[i] = Integer.parseInt(str[1]);
w[i] = Integer.parseInt(str[2]);
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= V; j++)
for (int k = 1; k <= M2; k++) {
f[i][j][k] = f[i - 1][j][k];
if (v[i] <= j && m[i] <= k)
f[i][j][k] = Math.max(f[i][j][k], f[i - 1][j - v[i]][k - m[i]] + w[i]);
}
System.out.println(f[n][V][M2]);
}
}