#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read()
{
    char c;
    ll w=1;
    while((c=getchar())>'9'||c<'0')if(c=='-')w=-1;
    ll ans=c-'0';
    while((c=getchar())>='0'&&c<='9')ans=(ans<<1)+(ans<<3)+c-'0';
    return ans*w;
}
struct node
{
	ll a,b;
	bool operator<(const node&w)const
	{
		return a+a+b<w.a+w.a+w.b;
	}
}e[1000005];
int n;
int main(){
	n=read();
	ll now=0;
	for(int i=1;i<=n;i++)
	{
		e[i].a=read();
		now-=e[i].a;
		e[i].b=read();
	}
	sort(e+1,e+n+1);
	for(int i=n;i>=1;i--)
	{
		if(now>0)
		{
			cout<<n-i<<endl;
			return 0;
		}
		now+=e[i].a;
		now+=e[i].a;
		now+=e[i].b;
	}
	if(now>0)
	{
		cout<<n<<endl;
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main () {
  int N;
  cin >> N;
  
  int temp = N;
  vector<int> vec;
  for(int i = 0; i < 10; i++) {
    vec.push_back(temp % 10);
    temp = temp / 10;
    if(temp == 0) {
      break;
    }
  }
  
  int count = 0;
  for(int i = 0; i < vec.size(); i++) {
    if(vec.at(i) != 0) {
      count = i;
      break;
    }
  }
  
  if (count != 0){
  	for(int i = 0; i < count; i++) {
    	vec.erase(vec.begin());
  	}
  }
  
  bool ret;
  if(vec.size() < 2) {
    ret = true;
  }
  else {
      int l = vec.size();
      l = l / 2;
	for(int i = 0; i < l; i++) {
   	 	int f = vec[i];
    	int b = vec[vec.size() - 1 - i];
    
        if(f == b) {
            ret = true;
        }
        else {
            ret = false;
            break;
        }
    }
  }
  
  if(ret) {
    cout << "Yes" << endl;
  } else {
    cout << "No" <<endl;
  }
  
  return 0;
}