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() for j in range(M+1): if j + w <= M: tmp = (dp[j] + v) * v if tmp > ans: ans = tmp else: break for j in range(M+1): if j + w <= M: nx[j+w] = max(nx[j+w],dp[j] + v) else: break dp = nx print(ans)