N,M = map(int,input().split()) l = [] for i in range(N): v,w = map(int,input().split()) l.append((v,w)) l.sort(reverse = True,key = lambda s:s[0]) #dp = [[0] * (M+1) for _ in range(N+1)] dp = [0] * (M+1) ans = 0 for i in range(N): v,w = l[i] nx = dp.copy() tmp = 0 for j in range(M+1-w): if tmp < dp[j]: tmp = dp[j] if ans < (tmp + v) * v: ans = (tmp + v) * v for j in range(M+1-w): nx[j+w] = max(nx[j+w],dp[j] + v) dp = nx print(ans)