import sys #input = sys.stdin.readline input = sys.stdin.buffer.readline #文字列はダメ #sys.setrecursionlimit(1000000) #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush #from collections import defaultdict #from collections import deque #import copy #import math #from functools import lru_cache #@lru_cache(maxsize=None) #MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] def main(): N,M = map(int,input().split()); INF = pow(10,18) V = []; W = []; Z = [] for i in range(N): v,w = map(int,input().split()) V.append(v) W.append(w) Z.append((v,w)) #宝石がの美しさが大きい順 Z.sort(reverse=True) #print(Z) #dp[i][j]:i番目を使って重さがjの時の美しさの総和の最大値 dp = [[-INF]*(M+1) for _ in range(N+1)] dp[0][0] = 0 #dps[i]:i番以下における重さがjの時の美しさの総和最大値 dps = [[-INF]*(M+1) for _ in range(N+1)] dps[0][0] = 0 for i in range(N): vi = Z[i][0]; wi = Z[i][1] #print(vi,wi) for j in range(M+1): nj = j + wi if nj <= M: dp[i+1][nj] = max(dp[i+1][nj], dps[i][j] + vi) dps[i+1][j] = max(dps[i][j], dp[i+1][j]) #print(dp[i+1]) #print(dps[i+1]) ans = 0 for i in range(N): for j in range(M+1): temp = dp[i+1][j] * Z[i][0] ans = max(ans, temp) print(ans) if __name__ == '__main__': main()