#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    vector<ll> dec;
    ll at = 0;
    rep(i, n) {
        cin >> a[i] >> b[i];
        at += a[i];
        dec.push_back(2 * a[i] + b[i]);
    }
    sort(dec.rbegin(), dec.rend());
    
    int ans = 0;
    while (at >= 0) {
        at -= dec[ans];
        ans++;
    }

    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>
#include <string>
using namespace std;

#define ll long long
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))

const int N =100;

bool isprime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i*i<=n; i++)
        if (n % i == 0)
            return false;

    return true;
}
ll binarySearch(ll arr[], ll l, int r, ll x,ll n)
{
	sort(arr,arr+n);
    if (r >= l) {
        ll mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x,n);
        return binarySearch(arr, mid + 1, r, x,n);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
bool ispalindrome(string s)
{
    int n = s.length();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            return false;
    }
    return true;
}
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);

}
ll f(ll n) {
	return n * (n - 1) / 2;
}
bool powerof2(ll n)
{
	return n!=0 && ((n&(n-1))==0);
}
double fact(double n)
{cout<<setprecision(9);
    if(n==0 ||n==1)
    return 1;
    else 
    return n*fact(n-1);
}
void solve()
{
	
	int n;
	cin>>n;
	int a[n][2];
	for(int i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1];
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int p = abs(a[j][1]-a[i][1]);
			int q = abs(a[j][0]-a[i][0]);
			if(p<=q)
			ans++;
		}
	}
	cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}