#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int t[3005],s[3005],a[3005],dp[10005];
bool cmp(int l, int r){
return -t[l]*s[r]>-t[r]*s[l];
}
int main(){
int n,m;
while(scanf("%d%d",&n,&m)==2){
memset(dp,128,sizeof(dp));
dp[0]=0;
for(int i=0;i<n;i++){
scanf("%d%d",t+i,s+i);
a[i]=i;
}
sort(a,a+n,cmp);
for(int o=0;o<n;o++){
int i=a[o];
for(int j=m;j>=t[i];j--)
dp[j]=max(dp[j],dp[j-t[i]]+(m-j+t[i])*s[i]);
}
printf("%d\n",*max_element(dp,dp+m+1));
}
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxhbGdvcml0aG0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgdFszMDA1XSxzWzMwMDVdLGFbMzAwNV0sZHBbMTAwMDVdOwoKYm9vbCBjbXAoaW50IGwsIGludCByKXsKICAgIHJldHVybiAtdFtsXSpzW3JdPi10W3JdKnNbbF07Cn0KCmludCBtYWluKCl7CiAgICBpbnQgbixtOwogICAgd2hpbGUoc2NhbmYoIiVkJWQiLCZuLCZtKT09Mil7CiAgICAgICAgbWVtc2V0KGRwLDEyOCxzaXplb2YoZHApKTsKICAgICAgICBkcFswXT0wOwogICAgICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgICAgICBzY2FuZigiJWQlZCIsdCtpLHMraSk7CiAgICAgICAgICAgIGFbaV09aTsKICAgICAgICB9CiAgICAgICAgc29ydChhLGErbixjbXApOwogICAgICAgIGZvcihpbnQgbz0wO288bjtvKyspewogICAgICAgICAgICBpbnQgaT1hW29dOwogICAgICAgICAgICBmb3IoaW50IGo9bTtqPj10W2ldO2otLSkKICAgICAgICAgICAgICAgIGRwW2pdPW1heChkcFtqXSxkcFtqLXRbaV1dKyhtLWordFtpXSkqc1tpXSk7CiAgICAgICAgfQogICAgICAgIHByaW50ZigiJWRcbiIsKm1heF9lbGVtZW50KGRwLGRwK20rMSkpOwogICAgfQp9Cg==