#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int a, b, c, d, m, n, k, tests, res = INF;
int Power[1000005];
int DP[1000005];
int SumPref[1000005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a, &b);
    Power[a] = b;
  }
  for (int i = 0; i <= 1000000; i++) {
    SumPref[i] = SumPref[max(0, i - 1)] + (Power[i] != 0);
  }
  for (int i = 0; i <= 1000000; i++) {
    DP[i] += DP[max(0, i - Power[i] - 1)];
    DP[i] += SumPref[i - 1] -
             ((i - Power[i] - 1 < 0) ? 0 : SumPref[i - Power[i] - 1]);
    res = min(res, DP[i] + SumPref[1000000] - SumPref[i]);
  }
  printf("%d\n", res);
}
