#include<bits/stdc++.h>
using namespace std;

#define xx first
#define yy second
typedef pair<int, int> pii;
typedef long long ll;

bool cmp(pii q, pii w)
{
    if(q.yy == w.yy)
        return q.xx > w.xx;
    return q.yy > w.yy;
}

bool cmp1(pii q, pii w)
{
    if(q.xx == w.xx)
        return q.yy > w.yy;
    return q.xx > w.xx;
}

int main()
{
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    int n, s;
    cin >> n >> s;
    vector<pii> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i].xx >> a[i].yy;
    sort(a.begin(), a.end(), cmp);
    for(int i = 0; i < n; i++)
    {
        if (a[i].xx < a[i].yy)
            continue;
        int t = min(s, a[i].xx / a[i].yy);
        s -= min(s, a[i].xx / a[i].yy);
        a[i].xx -= t * a[i].yy;
    }
    if(s > 0)
    {
        sort(a.begin(), a.end(), cmp1);
        for(int i = 0; i < n; i++)
        {
            if (s > 0 && a[i].xx > 0)
            {
                a[i].xx = 0;
                s--;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
        ans += a[i].xx;
    cout << ans;
    return 0;
}
