import sys input = sys.stdin.readline N, M = map(int, input().split()) VW = [tuple(map(int, input().split())) for _ in range(N)] VW.sort(reverse=True) dp = [0]*(M+1) ans = 0 for i in range(N): V, W = VW[i] ndp = [0]*(M+1) for j in range(M+1): ndp[j] = max(ndp[j], dp[j]) if j+W<=M: ndp[j+W] = max(ndp[j+W], dp[j]+V) ans = max(ans, ndp[j+W]*V) dp = ndp print(ans)