#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

void solve(int n, int s) {
    vector< pair<int, int> > a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &a[i].fi, &a[i].se);
    }

    for (int i = 0; i < s; i++) {
        int v = -1;
        for (int j = 0; j < n; j++) {
            if (v == -1 || min(a[v].fi, a[v].se) < min(a[j].fi, a[j].se)) {
                v = j;
            }
        }
        if (v == -1) break;
        a[v].fi = max(0, a[v].fi - a[v].se);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += a[i].fi;
    }

    printf("%d\n", ans);
}

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

    int n, s;
    while (scanf("%d%d", &n, &s) == 2) {
        solve(n, s);
    }
}
