#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";
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgIGxvbmcgbG9uZyBsbDsKCiNkZWZpbmUgTiAxMDAwMDA5CmxsIGJbTisxXSwgYVtOKzFdLCBwb3d3W04rMV0sIGRwW04rMV0sIHRkcFtOKzFdOwppbnQgbWFpbigpewoJbGwgaSxuLHRvdCA9IDA7CgljaW4gPj4gbjsKCWZvcihpPTE7aTw9bjtpKyspCgl7CgkJY2luID4+IGFbaV0gPj4gYltpXTsKCQlwb3d3W2FbaV1dPW1heChwb3d3W2FbaV1dLGJbaV0pOwoJCXRkcFthW2ldXSsrOwoJfQoJZHBbMV09ZHBbMF09MDsKCWZvcihpPTE7aTw9TjtpKyspewoJCXRkcFtpXSs9dGRwW2ktMV07Cgl9CQoJZm9yKGk9MTtpPD1OO2krKykKCXsKCQlpZihwb3d3W2ldPT0wKXsKCQkJZHBbaV09ZHBbaS0xXTsKCQl9CgkJZWxzZXsKCQkJaWYoaS1wb3d3W2ldLTE8MCl7CgkJCQlkcFtpXT0odGRwW2ktMV0pOwoJCQl9CgkJCWVsc2V7CgkJC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