#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

class Heap{

public:
    int* arr;
    int total;
    Heap(int maxtotal) {

        total = 0;
        arr = new int[maxtotal+1];

    }

    void sup(int v) {

        if(v == 1)
            return;

        int p = v/2;

        if(arr[v] > arr[p]) {

            swap(arr[v], arr[p]);
            sup(p);

        }

    }

    void sdown(int v) {

        if(2*v >= total)
            return;

        int c = 2*v;

        if(c+1 < total && arr[c+1] > arr[c])
            ++c;

        if(arr[c] > arr[v]) {

            swap(arr[c], arr[v]);
            sdown(c);

        }

    }

    int front() {

        return arr[1];

    }

    void pop() {

        --total;
        arr[1] = arr[total];
        sdown(1);

    }

    void push(int value) {

        ++total;
        arr[total-1] = value;
        sup(total-1);

    }

    int size() {

        return total;

    }

};

int main() {

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

    int totalWalls, totalUnits;
    cin >> totalWalls >> totalUnits;

    vector< pair<int,int> > src (totalWalls+1);

    long long ans = 0;

    for(int i=0; i<totalWalls; ++i) {

        cin >> src[i].second >> src[i].first;
        ans += src[i].second;
        src[i].first *= -1;
        src[i].second *= -1;

    }

    sort(src.begin(), src.end());

    for(int i=0; i<totalWalls; ++i) {
        src[i].first *= -1;
        src[i].second *= -1;
    }

    src[totalWalls].first = 0;
    src[totalWalls].second = 0;

    Heap past(totalWalls+5);

    for(int i=0; i<totalWalls; ++i) {

        while(totalUnits && past.size() && past.front() > src[i].first) {

            --totalUnits;
            ans -= past.front();
            past.pop();

        }

        if(!totalUnits)
            break;

        int sure = min(src[i].second/src[i].first, totalUnits);
        totalUnits -= sure;
        ans -= sure * src[i].first;
        src[i].second -= sure * src[i].first;
        if(src[i].second)
            past.push(src[i].second);

    }

    while(totalUnits && past.size()) {

        --totalUnits;
        ans -= past.front();
        past.pop();

    }

    cout << ans << endl;

    return 0;

}
