import sys readline = sys.stdin.readline N, V, C = map(int, readline().split()) v, w = [0] * N, [0] * N for i in range(N): v[i], w[i] = map(int, readline().split()) inf = 10 ** 18 dp = [[[-inf] * 2 for i in range(V + 1) ] for j in range(N + 1)] dp[0][0][0] = 0 for i in range(N): for j in range(V + 1): dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][0], dp[i][j][1]) if j - v[i] >= 0: dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i + 1][j - v[i]][0] + w[i] + C) dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i + 1][j - v[i]][1] + w[i]) ans = 0 for i in range(V + 1): ans = max(ans, dp[N][i][0], dp[N][i][1]) print(ans)