import sys input = sys.stdin.readline N, M = map(int, input().split()) T = [tuple(map(int, input().split())) for i in range(N)] dp = [[0] * (M + 1) for i in range(N + 1)] T.sort(reverse=True) ans = 0 TW = 0 for i in range(N): v, w = T[i] TW += w for j in range(min(M, TW + 1)): dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]) if j + w <= M: dp[i + 1][j + w] = max(dp[i + 1][j + w], dp[i][j] + v) ans = max(ans, dp[i + 1][j + w] * v) print(ans)