#include <bits/stdc++.h>
using namespace std;

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

int n;
int a[200005],b[200005],c[200005];
int suma,sumb;

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	cin>>n;
	forn(i,0,n){
		cin>>a[i]>>b[i];
		sumb+=a[i];
		c[i]=a[i]+b[i]+a[i];
	}
	sort(c,c+n);
	reverse(c,c+n);
	int cur=0;
	int sum=sumb-suma;
	while (sum>=0){
		sum-=c[cur];
		cur++;
	}
	cout<<cur<<endl;
	return 0;
}
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

void __dbg() { cout << endl; }
template<typename Arg, typename... Args> void __dbg(Arg A, Args... B) { cout << " " << A; __dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", __dbg(__VA_ARGS__)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define lprin(n) printf("%lld\n", n)
#define lpri(n) printf("%lld ", n)
#define lscn(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define pri(n) printf("%d ", n)
#define scn(n) scanf("%d", &n)
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

const int inf  = INT_MAX;
const int ninf = INT_MIN;
const int mod  = 1e9 + 7;
const int maxN = 1e6 + 2;

int main()
{
   int n;
   scn(n);

   vector<ll> a(n), b(n);
   vi order(n); iota(order.begin(), order.end(), 0);

   rep(i, 0, n) {
      lscn(a[i]); lscn(b[i]);   
   }

   ll B = 0, A = accumulate(a.begin(), a.end(), 0LL);

   sort(order.begin(), order.end(), [&](const int& i, const int& j){
      return (2 * a[i] + b[i]) > (2 * a[j] + b[j]);
   });

   rep(k, 0, n) {
      int i = order[k];

      B += a[i] + b[i];
      A -= a[i];

      if(B > A) {
         prin(k + 1);
         exit(0);
      }
   }

   assert(false);
   
   return 0;
}