n,v,c = map(int,input().split()) V = [] W = [] for i in range(n): a,b = map(int,input().split()) W.append(a) V.append(b) dp = [[0]*(v+1) for _ in range(n+1)] for i in range(n): for j in range(v+1): dp[i+1][j]=dp[i][j] if(j-W[i]>=0): if(dp[i+1][j]=0): dp[i+1][j]=max(dp[i+1][j],dp[i+1][j-W[i]]+V[i]) print(dp[-1][-1])