// AOJ 0303
#include<cstdio>
#include<algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

const int MAX_N = 1000, INF = 1001;

int N;
int c[MAX_N], w[MAX_N];
int wS[MAX_N];
bool P[MAX_N][MAX_N];
int dp[MAX_N];

int main()
{
	scanf( "%d", &N );
	rep( i, N )
		scanf( "%d%d", c+i, w+i );

	wS[0] = w[0];
	rep( i, N-1 )
		wS[i+1] = wS[i] + w[i+1];

	rep( i, N )
		P[i][i] = true;

	rep( w, N )
	{
		rep( i, N-w )
		{
			int j = i+w;
			
			if( !P[i][j] )
				continue;

			if( j+1 < N && wS[j]-(i-1>=0?wS[i-1]:0) <= c[j+1] )
				P[i][j+1] = true;
			if( i-1 >= 0 && wS[j]-(i-1>=0?wS[i-1]:0) <= c[i-1] )
				P[i-1][j] = true;
		}
	}

	std::fill( dp, dp+N, INF );

	dp[0] = 1;
	rep( i, N ) rep( j, N ) if( P[i][j] )
		dp[j] = std::min( dp[j], (i-1>=0?dp[i-1]:0)+1 ); 

	printf( "%d\n", dp[N-1] );

	return 0;
}