#include <array>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;
using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using vpii = vector<pii>; using vpll = vector<pll>;
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (const auto &x : v) os << x << " "; return os; }

void solve() {
	int n;
	cin >> n;
	vector<ll> a(n), b(n), x(n);
	ll suma = 0;
	for (int i=0; i<n; i++) {
		cin >> a[i] >> b[i];
		suma += a[i];
		x[i] = 2*a[i] + b[i];
	}
	sort(x.rbegin(), x.rend());
	ll score = -suma;
	int i = 0;
	while (score <= 0) {
		score += x[i]; 
		i++;
	}
	cout << i << endl;
}

int main() {
	solve();
	return 0;
}

//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
using namespace std;
#define Fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr)
#define f(i, n) for (long long int i = 0; i < n; i++)
#define ll long long int
#define fo(i, a, b) for (long long int i = a; i <= b; i++)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long int>>
#define mii map<int, int>
#define umii unordered_map<int, int>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define newl cout<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e9 + 7;
const ll mod = 1e9 + 7;
#define MAX 100005 

ll mini(ll a,ll b){
    if(a>=b)return b;
    return a;
}

ll maxi(ll a,ll b){
    if(a>=b)return a;
    return b;
}

bool cmp(pair<ll,ll> a,pair<ll,ll>b){
    return a.fi>b.fi;
}

int main(){
	Fio;
    ll n;
    cin>>n;
    vector<ll>A;
    ll ao = 0,taka = 0;
    fo(i,1,n){
        ll x,y;
        cin>>x>>y;
        A.pb(2*x+y);
        ao+=x;
    }
    sort(A.rbegin(),A.rend());
    ll ans = 0;
    fo(i,0,n-1){
        taka += A[i];
        ans++;
        if(taka>ao)break;
    }
    cout<<ans;

    return 0;
}
