#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int N, c[1000], w[1000], sum[1000];

int s(int l, int r){
	return (r-1 < 0 ? 0 : sum[r-1]) - (l-1 < 0 ? 0 : sum[l-1]);
}

int memo2[1000][1001];
bool sol(int l, int r){ //[l,r)
	if(r-l == 1) return true;
	if(memo2[l][r] != INT_MIN) return memo2[l][r];
	bool ret = false;
	if(c[l] >= s(l+1, r) && sol(l+1, r)) ret = true;
	if(c[r-1] >= s(l, r-1) && sol(l, r-1)) ret = true;
	return memo2[l][r] = ret;
}

int memo[1000];
int solve(int l){
	if(l == N) return 0;
	if(memo[l] != INT_MIN) return memo[l];
	int ret = INT_MAX;
	for(int i=l+1; i<=N; i++){
		if(sol(l, i)) ret = min(ret, solve(i)+1);
	}
	return memo[l] = ret;
}

signed main(){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> c[i] >> w[i];
		sum[i] = (i == 0 ? 0 : sum[i-1]) + w[i];
		memo[i] = INT_MIN;
		for(int j=0; j<N; j++) memo2[i][j+1] = INT_MIN;
	}
	cout << solve(0) << endl;
}
