#include <iostream>
#include <math.h>
#include <string>
#include <cstdlib>
using namespace std;

int main() {
	int exam=0;
	int timePassed=0;
	int n;
	cin>>n;
	int **TD = new int*[2];
	for(int count=0;count<2;count++)
	{
		TD[count]=new int [n];
	}
	for(int i=0;i<n;i++)
	{
		cin>>TD[1][i];
		cin>>TD[0][i];
	}
	for(int i=0;i<n;i++)
	{
		for(int o=0;o<n;o++)
		{
			if(TD[1][i]<TD[1][o])
			{
				int table=TD[1][o];
				TD[1][o]=TD[1][i];
				TD[1][i]=table;
				int tabletwo=TD[0][o];
				TD[0][o]=TD[0][i];
				TD[0][i]=tabletwo;
				
			}

		}
	}	
	for(int i=0;i<n;i++)
	{
		if(TD[0][i]<=(TD[1][i]-timePassed))
		{
			exam++;
			timePassed=timePassed + TD[0][i];
		}
	}
	cout<<exam;
	
	
	return 0;
}
