#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;
class wall
{
public:
    int a;
    int k;
};

bool operator<(wall a,wall b)
{
    if (b.k!=a.k){return a.k>b.k;}
    return (a.a%a.k>b.a%b.k);
}

bool comp(wall a,wall b)
{
    return (a.a>b.a);
}

int main()
{
    ifstream f1("castle.in");
    ofstream f2("castle.out");
    int n,s;
    f1 >> n >> s;
    vector<wall> w;
    for (int i=0;i<n;i++)
    {
        int a,k;
        f1 >> a >> k;
        wall w1;
        w1.a=a;
        w1.k=k;
        w.push_back(w1);
    }
    sort(w.begin(),w.end());
    int res=0;
    for (int i=0;i<n&&res<s;i++)
    {
      //  cout  << w[i].a << ' ' << w[i].k << endl;
        if (res+w[i].a/w[i].k<=s){res+=w[i].a/w[i].k;w[i].a=w[i].a%w[i].k;continue;}
        w[i].a-=(s-res)*w[i].k;
        res=s;
       // cout  << ' ' << w[i].a << ' ' << w[i].k << endl;
    }
    //cout << endl;
    sort(w.begin(),w.end(),comp);
    for (int i=0;i<n&&res<s;i++)
    {
               // cout  << w[i].a << ' ' << w[i].k << endl;
        if (w[i].a>0){res++;w[i].a=0;}else{break;}
               // cout  << ' ' << w[i].a << ' ' << w[i].k << endl;
    }
    unsigned long long int sum=0;
    for (int i=0;i<n;i++)
    {
        //cout << w[i].a << endl;
        sum+=w[i].a;

    }
    f2 << sum;
    return 0;
}
