#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
 
using namespace std;
typedef long long ll;
 
#define mod 1000000007
#define INF 1000000000
#define SIZE 1000
int n,c[SIZE],w[SIZE];
bool memo[SIZE][SIZE];

void dfs(int l,int r,int now,int weight){
  if(l < 0 || n <= r) return;
  if(memo[l][r]) return;
  
  if(c[now] < weight) return;

  memo[l][r] = true;

  //cerr << "(" << l << "," << r << ")" << endl;
  
  weight += w[now];
  
  dfs(l,r+1,r+1,weight);
  dfs(l-1,r,l-1,weight);

}
  

int main(){
  int l[SIZE],r[SIZE];
  int dp[SIZE+10];
  
  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%d%d",&c[i],&w[i]);
  }

  for(int i=0;i<n;i++){
    dfs(i,i,i,0);
  }
  
  for(int i=0;i<=n;i++){
    dp[i] = INF;
  }

  dp[0] = 0;

  for(int i=0;i<n;i++){

    for(int j=i;j<n;j++){
      if(memo[i][j]) dp[j+1] = min(dp[j+1],dp[i]+1);
    }

  }

  cout << dp[n] << endl;
  
  return 0;
}