N, V, M = map(int, input().split())
A = []
for i in range(N):
v, m, w = map(int, input().split())
A.append((v, m, w))
F = [[0 for _ in range(V+1)] for _ in range(M+1)] # F[M][V]
for i in range(N):
v, m, w = A[i]
for j in range(M, m-1, -1):
for k in range(V, v-1, -1):
F[j][k] = max(F[j][k], F[j-m][k-v] + w)
print(max(max(F)))