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

using namespace std;

vector<pair<int, int> > towers;
vector<int> mods;

bool compare(pair<int, int> a, pair<int, int> b)
{
    return a.second <= b.second;
}

int main()
{
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    int n, s;
    cin >> n >> s;
    long long perfectguards = 0;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        if (b == 0)
        {
            return 0;
        }
        towers.push_back(make_pair(a / b, b));
        perfectguards += a / b;
        if (a % b > 0)
        {
            perfectguards++;
            mods.push_back(a % b);
        }
    }
    if (perfectguards <= s)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(towers.begin(), towers.end(), compare);
    sort(mods.begin(), mods.end());
    cout << 0 << endl;
    return 0;
    for (int i = 0; i < mods.size(); i++)
    {
        cerr << mods[i] << endl;
    }
    for (int i = 0; i < towers.size(); i++)
    {
        cerr << towers[i].first << " " << towers[i].second << endl;
    }
    long long intruders = 0;
    int towerno = 0;
    int modno = 0;
    int curtow = towers[0].first;
    while (perfectguards > s)
    {
        if (curtow == 0 && towerno < (n - 1))
        {
            towerno++;
            curtow = towers[towerno].first;
        }
        else
        {
            if (modno < mods.size() && (towerno == n || (mods[modno] <= towers[towerno].second)))
            {
                if (modno >= mods.size())
                {
                    cout << "Presentation error." << endl << ":)";
                    return 0;
                }
                intruders += mods[modno];
                modno++;
                perfectguards--;
            }
            else
            {
                if (towerno >= n)
                {
                    cout << "Presentation error." << endl << ":)";
                    return 0;
                }
                intruders += towers[towerno].second;
                curtow--;
                perfectguards--;
            }
        }
        if (modno == mods.size() && towerno == n && perfectguards > s)
        {
            cout << "Presentation error." << endl << ":)";
            return 0;
        }
    }
    cout << intruders << endl;
    return 0;
}
