#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define INF 1e9

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;

  vi w = vi(n, 0);
  vi csum = vi(n, 0);
  vi c = vi(n, 0);
  REP(i, n)
  {
    cin >> c[i] >> w[i];
  }
  vvi dp = vvi(n, vi(n, INF));
  REP(i, n)
  {
    dp[i][i] = 1;
  }
  csum[0] = w[0];
  for (int i = 1; i < n; i++)
  {
    csum[i] = csum[i - 1] + w[i];
  }
  for (int count = 2; count <= n; count++)
  {
    REP(left, n)
    {
      int right = left + count - 1;
      if (right >= n)
      {
        continue;
      }

      // 一番下が一人になる時
      if (csum[right] - csum[left] <= c[left] && dp[left + 1][right] == 1)
        dp[left][right] = 1;
      if (csum[right - 1] - csum[left - 1] <= c[right] && dp[left][right - 1] == 1)
        dp[left][right] = 1;

      // min
      for (int k = left; k < right; k++)
      {
        dp[left][right] = min(dp[left][right], dp[left][k] + dp[k + 1][right]);
      }
    }
  }
  cout << dp[0][n - 1] << endl;
  return 0;
}
