#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <map>
#include <vector>
#define REP_(i, a_, b_, a, b, ...) \
    for (int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(obj) obj.begin(), obj.end()

using namespace std;
using Int = int64_t;

int main() {
    Int N;
    cin >> N;
    vector<Int> vec;
    Int sum = 0;
    
    REP(i, N) {
        Int a, b;
        cin >> a >> b;
        vec.push_back(2 * a + b);
        sum -= a;
    }

    sort(ALL(vec));
    reverse(ALL(vec));
    REP(i, N) {
        sum += vec[i];
        if (sum > 0) {
            cout << i + 1 << endl;
            break;
        }
    }
    
    return 0;
}
// #include<vector>
// #include<iostream>
// #include<stdio.h>
// #include<string>
// #include<algorithm>
#include<bits/stdc++.h>
using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	if ( b >= 8 && a+b >= 15) {
		cout << 1 << endl;
		return 0;
	}
	if ( b >= 3 && a+b >= 10) {
		cout << 2 << endl;
		return 0;
	}
	if ( a+b >= 3) {
		cout << 3 << endl;
		return 0;
	}
	cout << 4 << endl;
}