INF = 1 << 60 n, m = map(int, input().split()) items = [list(map(int, input().split())) for _ in range(n)] items.sort(key=lambda x: x[0]) ans = 0 dp = [- INF for _ in range(m + 1)] dp[0] = 0 for _ in range(n): v, w = items.pop() for i in range(m - w, -1, -1): ans = max(ans, v * (dp[i] + v)) dp[i + w] = max(dp[i + w], dp[i] + v) print(ans)