#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VVI = vector<VI>;
using PII = pair<ll, ll>;
const ll LLINF = (1LL << 60);
const ll INF = (1LL << 30);
const ll MOD = 1000000007;
template <typename T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <typename T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
template <typename T>
bool IN(T a, T b, T x) {
  return a <= x && x < b;
}
template <typename T>
T ceil(T a, T b) {
  return a / b + !!(a % b);
}
template <class S, class T>
ostream &operator<<(ostream &out, const pair<S, T> &a) {
  out << '(' << a.first << ',' << a.second << ')';
  return out;
}
template <class T>
ostream &operator<<(ostream &out, const vector<T> &a) {
  out << '[';
  for (ll i = (ll)0; i < (ll)a.size(); ++i) {
    out << a[i];
    if (i != a.size() - 1) out << ',';
  }
  out << ']';
  return out;
}
ll dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (true) {
    double EPS = 1e-8;
    double length = 1e6;
    ll n;
    cin >> n;
    if (!n) break;
    VI t(n), c(n);
    vector<PII> p(n);
    for (ll i = (ll)0; i < (ll)n; ++i) {
      cin >> t[i] >> c[i];
      p[i] = pair<double, ll>{t[i], c[i]};
    }
    sort(p.begin(), p.end());
    vector<double> v(n);
    for (ll i = (ll)0; i < (ll)n; ++i) v[i] = length / p[i].first;
    vector<pair<double, ll>> place(n, {0, 0});
    vector<pair<double, ll>> nxt(n, {0, 0});
    ll i, num;
    for (i = 0, num = 0; num < n; ++i) {
      for (ll j = (ll)0; j < (ll)n; ++j) {
        if (place[j].second >= c[j]) continue;
        double tmp = place[j].first + v[j];
        for (ll k = (ll)0; k < (ll)n; ++k) {
          if (j == k) continue;
          if (place[k].second >= p[k].second) continue;
          if (place[j].first < EPS && place[k].first < EPS) continue;
          if (abs(place[j].first - length) < EPS &&
              abs(place[k].first - length) < EPS)
            continue;
          if (place[j].first <= place[k].first &&
              place[j].first + v[j] > place[k].first + v[k]) {
            chmin(tmp, place[k].first + v[k]);
          }
        }
        if (place[j].first < 2 * length && 2 * length <= tmp + EPS) {
          nxt[j] = pair<double, ll>{0, place[j].second + 1};
          if (nxt[j].second >= p[j].second) num++;
        } else {
          nxt[j] = pair<double, ll>{tmp, place[j].second};
        }
      }
      place = nxt;
    }
    cout << i << endl;
  }
  return 0;
}
