#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define mkp make_pair
#define F first
#define S second
const int maxn = 105;
const int maxs = 10005;
const int inf = (int)1e9 + 100;
int dp[maxn][maxs];

struct node {
    int a, k, i;
    double x;
    node(double x = 0, int a = 0, int k = 0, int i = 0) : x(x), a(a), k(k), i(i) {}
    bool operator < (node b) const {
        return x < b.x;
    }
} v[maxn];

int main() {
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    int n, s;
    scanf("%d %d", &n, &s);
    for (int i = 1; i <= n; ++i) {
        int a, k;
        scanf("%d %d", &a, &k);
        double x = ((double)a / (double)k);
        v[i] = node(x, a, k, i);
    }
    sort(v + 1, v + n + 1);
    reverse(v + 1, v + n + 1);
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (s >= (v[i].a / v[i].k) + (v[i].a % v[i].k != 0)) {
            s -= (v[i].a / v[i].k) + (v[i].a % v[i].k != 0);
        } else {
            int cur = min(s, (v[i].a / v[i].k) + (v[i].a % v[i].k != 0));
            s -= cur;
            ans += v[i].a - cur * v[i].k;
        }
    }
    cout << ans;
    return 0;
}
/*
3 3
4 2
1 1
10 8
*/


