h,w=map(int,input().split())
dp=[0]*(w+1)
for i in range(h):
    p,t=map(int,input().split())
    new_dp=dp[:]
    for i in range(p,w+1):
        new_dp[i]=max(new_dp[i],dp[i-p]+p*t)
    dp=new_dp
print(max(dp))
