import sys import pypyjit import itertools import heapq import math from collections import deque, defaultdict, Counter import string import random input = sys.stdin.readline sys.setrecursionlimit(10 ** 6) pypyjit.set_param('max_unroll_recursion=-1') N, Pmax, C = map(int, input().split()) P = [tuple(map(int, input().split())) for _ in range(N)] dp = [0 for _ in range(Pmax + 1)] for i in range(N): price, value = P[i] value += C for j in range(Pmax + 1)[::-1]: if j - price < 0: break dp[j] = max(dp[j], dp[j - price] + value) for i in range(N): price, value = P[i] for j in range(Pmax + 1): if j - price < 0: continue dp[j] = max(dp[j], dp[j - price] + value) print(max(dp))