'''
简单二维费用01背包
dp(i, j, k)表示前i种物品中做选择,所有第一维总消耗不超过j,第二位总消耗不超过k
的所有可能选法中总价值的最大值
'''
dp = [[0] * 120 for _ in range(120)]
N, V, M = map(int, input().split())
arr = []
for i in range(N):
v, m, w = map(int, input().split())
arr.append((v, m, w))
for i in range(N):
for j in range(V, -1, -1):
for k in range(M, -1, -1):
if i == 0:
dp[j][k] = arr[i][2] if j >= arr[i][0] and k >= arr[i][1] else 0
else:
if j >= arr[i][0] and k >= arr[i][1]:
dp[j][k] = max(dp[j][k], arr[i][2] + dp[j-arr[i][0]][k-arr[i][1]])
print(dp[V][M])