#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>

int main()
{
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

	int n;
	int t=0;
	std::vector<std::pair<int,int> > v;
	std::priority_queue<int,std::vector<int>,std::greater<int> > q;
	scanf("%d",&n);
	v.reserve(n+1);
	v.push_back(std::pair<int,int>(0,0));
	for(int i=0;i<n;++i)
	{
		int T,D;
		scanf("%d%d",&T,&D);
		v.push_back(std::pair<int,int>(T,D));
	}
	std::sort(v.begin(),v.end());
	for(int k=n;k>0;--k)

	{
		q.push(v[k].second);
		int t=v[k].first-v[k-1].first;
		while(t>0&&!q.empty())
		{
			int d=q.top();
			q.pop();
			if(t>=d) t-=d;
			else {q.push(d-t);t=0;}
		}
	}
	printf("%d\n",n-q.size());
	return 0;
}
