    # include <bits/stdc++.h>
    #define rep(i,l,r)for(int i=(l);i<(r);i++)
    # define rrep(i,r,l) for(int i=(r); i>=l; --i)
    # define ALL(x) (x).begin(), (x).end()
    # define SZ(x) ((int)(x).size())
    # define pb push_back
    # define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
    using namespace std;
    typedef long long lint;
    template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    #define INF ((1LL<<62)-(1LL<<31)) /*オーバーフローしない程度に大きい数*/
    #define MOD 1000000007
    lint gcd(lint a,lint b){
        if(!b)return a;
        return gcd(b,a%b);
    }
    
    lint lcm(lint a,lint b){
        return a*b/gcd(a,b);
    }
    struct node{
        int parent,cost;
    };

    bool comp(pair<lint,lint> p,pair<lint,lint> q){
        return p.first-p.second > q.first - q.second;
    }

    void solve() {
        lint N;
        cin >> N;
        vector<pair<lint,lint>> A(N);
        lint tmp =0;
        rep(i,0,N){
            lint a,b;
            cin >> a >> b;
            A[i].first=a+b;
            A[i].second=-a;
            tmp+=A[i].second;
        }
        
        sort(A.begin(),A.end(),comp);
        lint ans=0;
        int i=0;
        while(tmp<=0){
            tmp+=A[i].first-A[i].second;
            i++;
            ans++;
        }

        cout << ans << endl;
    }

    signed main() {

        solve();

        return 0;
    }
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
  return 2 * a.first + a.second > 2 * b.first + b.second;
}

int main() {
  int N;
  ll a, b, sumA = 0, sumB = 0;
  vector<pair<ll, ll>> C;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a >> b;
    sumA += a;
    C.emplace_back(a, b);
  }
  sort(C.begin(), C.end(), comp);

  int ans = 0;
  for (auto[a, b]: C) {
    if (sumB > sumA) break;
    sumB += a + b;
    sumA -= a;
    ans++;
  }

  cout << ans << endl;
}
