#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const double EPS = (long double)1e-7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = (0); i < (int)(n); ++i) cin >> a[i] >> b[i];
  vector<pair<int, int> > scoreboard(n);
  for (int i = (0); i < (int)(n); ++i) scoreboard[i] = {-a[i], i};
  sort((scoreboard).begin(), (scoreboard).end());
  vector<int> init(n), pos, neg;
  for (int i = (0); i < (int)(n); ++i) {
    for (int j = (0); j < (int)(n); ++j)
      if (scoreboard[j].second == i) init[i] = j;
    if (b[i] > 0)
      pos.push_back(i);
    else
      neg.push_back(i);
  }
  sort((pos).begin(), (pos).end(),
       [&](int a, int b) { return init[a] > init[b]; });
  sort((neg).begin(), (neg).end(),
       [&](int a, int b) { return init[a] < init[b]; });
  vector<vector<int> > dp(n + 1, vector<int>(n + 1, -1));
  dp[pos.size()][neg.size()] = 0;
  function<int(int, int, vector<pair<int, int> >)> f =
      [&](int x, int y, vector<pair<int, int> > s) {
        if (dp[x][y] + 1) return dp[x][y];
        if (x < pos.size()) {
          int t = pos[x];
          int tt = 0;
          vector<pair<int, int> > ss = s;
          for (int i = (0); i < (int)(n); ++i) {
            if (ss[i].second == t) {
              tt = i;
              ss[i].first -= b[t];
            }
          }
          int cnt = 0;
          while (tt && ss[tt] < ss[tt - 1]) {
            swap(ss[tt], ss[tt - 1]);
            tt--, cnt++;
          }
          dp[x][y] = max(dp[x][y], cnt + f(x + 1, y, ss));
        }
        if (y < neg.size()) {
          int t = neg[y];
          int tt = 0;
          vector<pair<int, int> > ss = s;
          for (int i = (0); i < (int)(n); ++i) {
            if (ss[i].second == t) {
              tt = i;
              ss[i].first -= b[t];
            }
          }
          int cnt = 0;
          while (tt < ss.size() - 1 && ss[tt] > ss[tt + 1]) {
            swap(ss[tt], ss[tt + 1]);
            tt++, cnt++;
          }
          dp[x][y] = max(dp[x][y], cnt + f(x, y + 1, ss));
        }
        return dp[x][y];
      };
  cout << f(0, 0, scoreboard) << endl;
  return 0;
}
