#include <bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    ifstream cin("castle.in");
    ofstream cout("castle.out");

    int n,s;
    cin>>n>>s;

    priority_queue<pii> q;
    for(int i=0,ai,ki; i<n; i++)
        cin>>ai>>ki,q.push({min(ki,ai),ai});

    while(s>0&&!q.empty())
    {
        pii c=q.top();
        q.pop();
        if(s>=c.ss/c.ff)
        {
            s-=c.ss/c.ff;
            c.ss%=c.ff;
            c.ff=c.ss;
        }
        else
            c.ss-=c.ff*s,
            s=0;
        if(c.ss>0)
            q.push(c);
    }

    long long ans=0;
    while(!q.empty())
        ans+=q.top().ss,q.pop();
    cout<<ans;
    return 0;
}
