#include<bits/stdc++.h>
using namespace std;

typedef  long long ll;

#define N 1000009
ll b[N+1], a[N+1], poww[N+1], dp[N+1], tdp[N+1];
int main(){
	ll i,n,tot = 0;
	cin >> n;
	for(i=1;i<=n;i++)
	{
		cin >> a[i] >> b[i];
		poww[a[i]]=max(poww[a[i]],b[i]);
		tdp[a[i]]++;
	}
	dp[1]=dp[0]=0;
	for(i=1;i<=N;i++){
		tdp[i]+=tdp[i-1];
	}	
	for(i=1;i<=N;i++)
	{
		if(poww[i]==0){
			dp[i]=dp[i-1];
		}
		else{
			if(i-poww[i]-1<0){
				dp[i]=(tdp[i-1]);
			}
			else{
				dp[i]=(tdp[i-1]-tdp[i-poww[i]-1])+dp[i-poww[i]-1];
			}
		}
	}
	tot = INT_MAX;
	for(i=1;i<=n;i++){
		tot = min(tot,n-tdp[a[i]]+dp[a[i]]);
	}
	cout << tot << "\n";
}