#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  int n;
  cin>>n;
  vector<int> c(n),w(n);
  rep(i,n) cin>>c[i]>>w[i];
  vector<int> acc(n+1,0);
  rep(i,n) acc[i+1] = acc[i]+w[i];
  // w[i...j) = acc[j]-acc[i]

  vector<vector<bool>> rdp(n, vector<bool>(n+1, false));
  // [i,r) ok?
  rep(i,n) rdp[i][i+1] = true;
  repl(d,2,n+1) rep(i,n){
    int j=i+d;
    if(j>n) break;
    if(c[i] >= acc[j]-acc[i+1] && rdp[i+1][j]) rdp[i][j] = true;
    if(c[j-1] >= acc[j-1]-acc[i] && rdp[i][j-1]) rdp[i][j] = true;
  }

  vector<vector<int>> dp(n, vector<int>(n+1,INF));
  // dp[i][j] i?????§?????????[0,j)?????????????????????
  dp[0][0] = 1;
  dp[0][1] = 1;
  repl(i,1,n){
    rep(j,i+1) dp[i][j] = dp[i-1][j]+1;
    rep(j,i+1) if(rdp[j][i+1]) dp[i][i+1] = min(dp[i][i+1], dp[i-1][j]+j-i+1);
  }

  cout << *min_element(all(dp[n-1])) << endl;

  return 0;
}