#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>

using namespace std;

typedef long long ll;

const int N = 100005;

pair<ll, ll> a[N];

bool comp(pair<ll, ll> fs, pair<ll, ll> sc) {
    return fs.second > sc.second;
}

int main() {
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);

    int n;
    ll s;
    cin >> n >> s;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a + n, comp);
    for (int i = 0; i < n; ++i) {
        ll nd = a[i].first / a[i].second + (a[i].first % a[i].second != 0);
        ll here = min(s, nd);
        s -= here;
        a[i].first -= here * a[i].second;
        if (a[i].first > 0) ans += a[i].first;
    }
    cout << ans;
    return 0;
}