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