#include <bits/stdc++.h>0

using namespace std;

#define forn(i, n) for (int i = 0; i < n; i++)
#define sqr(a) ((a) * (a))
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define sz(a) (a.size())
#define all(a) a.begin(), a.end()
#define NAME "castle"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);

typedef long long ll;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int INF = 2e9;
const ll INF64 = 9e18;
const int N = 100100;
const int M = 1010;


int n;
ll s, ans;
pll a[N];
vector < ll > b;

int main()
{
    FREOPEN;
    cin >> n >> s;
    forn(i, n)
    {
        scanf("%I64d %I64d", &a[i].y, &a[i].x);
        ans += a[i].y;
    }
    sort(a, a + n);
    reverse(a, a + n);
    forn(i, n)
    {
        ll q = a[i].y / a[i].x;
        if (q <= s)
        {
            ans -= a[i].x * q;
            s -= q;
            if (a[i].y - a[i].x * q > 0)
                b.pb(a[i].y - a[i].x * q);
        }
        else
        {
            q = min(q, s);
            ans -= a[i].x * q;
            s -= q;
            if (a[i].y - a[i].x * q > 0)
                b.pb(a[i].y - a[i].x * q);
        }
    }
    sort(all(b));
    reverse(all(b));
    forn(i, min((int)sz(b), (int)s))
        ans -= b[i];

    cout << ans;
    return 0;
}


/*

1 10
8 1


3 3
4 2
1 1
10 8


*/



