#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define mkp make_pair
#define F first
#define S second

struct node {
    int x, a, k, i;
    node(int x = 0, int a = 0, int k = 0, int i = 0) : x(x), a(a), k(k), i(i) {}
    bool operator < (node b) const {
        if (x == b.x) {
            if (a % k == b.a % b.k) {
                return k > b.k;
            }
            return a % k > b.a % b.k;
        }
        return x < b.x;
    }
};

int main() {
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, s;
    cin >> n >> s;
    vector<node> v(n);
    for (int i = 0; i < n; ++i) {
        int a, k;
        cin >> a >> k;
        int x = (a / k) + (a % k != 0);
        v[i] = node(x, a, k, i);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (s >= v[i].x) s -= v[i].x;
        else {
            v[i].a -= v[i].k * s;
            s = 0;
            ans += v[i].a;
        }
    }
    cout << ans;
    return 0;
}
