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

struct wall {
    int a, k;
    wall() {};
    wall(int a, int k): a(a), k(k) {};
    void read() {scanf("%d %d", &a, &k);}
};

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

int main() {
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, s;
    cin >> n >> s;
    priority_queue<wall, vector<wall>, less<wall>> a;

    int maxi = 0;
    for (int i = 0; i < n; i++) {
        wall tmp; tmp.read();
        maxi += tmp.a;
        a.push(tmp);
        wall w = a.top();
    }

    while (s > 0 && maxi > 0) {
        if (s == 0 || maxi <= 0) break;
        wall w = a.top();
        a.pop();
        int q = min(s, w.a / w.k);
        s -= q;
        maxi -=  q * w.k;
        w.a -= q * w.k;
        a.push(w);
    }

    cout << max(0, maxi) << endl;
    return 0;
}

