#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
vector<int> c, w;
int ruiseki[1005];
bool dp[1005][1005];

/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    c.resize(n);
    w.resize(n);
    REP(i, n) cin >> c[i] >> w[i];

    ruiseki[0] = w[0];
    FOR(i, 1, n) ruiseki[i] = ruiseki[i-1] + w[i];
    
    REP(i, n) REP(j, n) dp[i][j] = false;
    REP(i, n) dp[i][i] = true;

    for(int len = 2; len <= n; len++){
        REP(l, n){
            int r = l + len - 1;
            if(r >= n) break;
            if(dp[l][r-1]){
                int weight = ruiseki[r-1];
                if(l != 0) weight -= ruiseki[l-1];
                dp[l][r] |= weight <= c[r];
            }
            if(dp[l+1][r]){
                int weight = ruiseki[r] - ruiseki[l];
                dp[l][r] |= weight <= c[l];
            }
        }
    }

    vector<int> ans(n, INF);
    ans[0] = 1; // ans[n] := n番目までで下にいる最低人数

    for(int r = 1; r < n; r++){
        ans[r] = ans[r-1] + 1;
        for(int l = 0; l < r; l++){
            if(dp[l][r]){
                if(l == 0) ans[r] = min(ans[r], 1);
                else ans[r] = min(ans[r], ans[l-1] + 1);
            }
        }
    }

    cout << ans[n-1] << endl;
}

