#include <iostream>

using namespace std;

int positive(int n, int a[]) {
    int k = 0;
    for (int i = 0; i < n;i++) if (a[i] > 0) k++;
    return k;
}

int min_(int n, int a[]) {
    int k = 0;
    while (a[k] <= 0) k++;
    int min1 = a[k];
    for (int i = 0; i < n; i++) if ((a[i] < min1) && (a[i] > 0)) min1 = a[i];
    return min1;
}

int max_(int n, int a[]) {
    int min1 = a[0];
    for (int i = 0; i < n; i++) if (a[i] > min1) min1 = a[i];
    return min1;
}

int min_i(int n, int a[]) {
    int min1 = 0;
    for (int i = 0; i < n; i++) if (a[i] < a[min1]) min1 = i;
    return min1;
}

int main()
{
    int n,t[10000],d[10000],k = 0;
    cin >> n;
    for (int i = 0; i< n; i++) {
        cin >> t[i] >> d[i];
    }
    while ((max_(n,t) > 0) || positive(n,t) == 1) {
        if (min_(n,d) < t[min_i(n,d)]) {
            t[min_i(n,d)] = -1;
            d[min_i(n,d)] = -1;
        } else {
            for (int i = 0; i < n; i++) {
                t[i] -= min_(n,d);
            }
        }
        k++;
    }
    cout << k - 2;
    return 0;
}
