#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector<int> vi;

int main(){
  int n;
  cin >> n;
  vi c(n), w(n);
  rep(i,n)cin >> c[i] >> w[i];

  vi sum(n+1,0);
  rep(i,n)sum[i+1] = sum[i] + w[i];

  vector<vi> can(n,vi(n,0));
  rep(i,n)can[i][i] = 1;

  for(int len=1;len<n;len++){
    rep(l,n-len){
      int r = l+len;
      if(can[l+1][r] && sum[r+1]-sum[l+1]<=c[l])can[l][r] = 1;
      if(can[l][r-1] && sum[r]-sum[l]<=c[r])can[l][r] = 1;
    }
  }

  vector<int> dp(n+1,n);
  dp[0] = 0;

  rep(i,n){
    rep(k,i+1){
      if(can[k][i])dp[i+1] = min(dp[i+1], dp[k]+1);
    }
  }
  cout << dp[n] << endl;
}