N, volume = map(int, input().split()) dp = [0 for _ in range(volume + 1)] for _ in range(N): volume_, price = map(int, input().split()) for v in range(volume_, volume + 1): dp[v] = max(dp[v], dp[v - volume_] + price) print(dp[-1])