n, m = map(int, input().split()) VW = [] for i in range(n): v, w = map(int, input().split()) VW.append((v, w)) VW.sort(key=lambda x: -x[0]) dp = [0]*(m+1) ans = 0 for v, w in VW: for i in reversed(range(m+1)): if i+w <= m: ans = max(ans, (dp[i]+v)*v) dp[i+w] = max(dp[i+w], dp[i]+v) print(ans)