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

bool operator<(wall a,wall b)
{
    return (min(a.a,a.k)>min(b.a,b.k));
}

     vector<wall> w;
int main()
{
    ifstream f1("castle.in");
    ofstream f2("castle.out");
    int n,s;
    f1 >> n >> s;
    for (int i=0;i<n;i++)
    {
        int a,k;
        f1 >> a >> k;
        wall w1;
        w1.k=k;
        w1.a=(a/k)*k;
        wall w2;
        w2.a=a%k;
        w2.k=k;
        w.push_back(w1);
        w.push_back(w2);
    }
    sort(w.begin(),w.end());
    int res=0;
    for (int i=0;i<w.size()&&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;

    unsigned long long int sum=0;
    for (int i=0;i<w.size();i++)
    {
        //cout << w[i].a << endl;
        sum+=w[i].a;

    }
    f2 << sum;
    return 0;
}
