#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
void _max(T &a, U b) {
  if (a < b) a = b;
}
template <typename T, typename U>
void _min(T &a, U b) {
  if (a > b) a = b;
}
const int N = 1000005;
long long power(long long n, long long p) {
  long long x = 1;
  while (p) {
    if (p % 2) x = (x * n) % 1000000007;
    if (p /= 2) n = (n * n) % 1000000007;
  }
  return x;
}
int p[N], cnt[N], dp[N];
int main() {
  int n, i, j, a, b, maxb = 0, count = 0, ans = N;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    p[a] = b;
    maxb = (maxb > a ? maxb : a);
  }
  for (i = 0; i <= maxb; i++) cnt[i] = cnt[i - 1] + (p[i] ? 1 : 0);
  for (i = 0; i <= maxb; i++) {
    if (p[i]) {
      if (i - p[i] - 1 < 0)
        dp[i] = cnt[i - 1];
      else
        dp[i] = cnt[i - 1] - cnt[i - p[i] - 1] + dp[i - p[i] - 1];
    } else
      dp[i] = dp[i - 1];
  }
  ans = dp[maxb];
  for (i = maxb; i >= 0; i--)
    ans = min(ans, dp[i - 1] + cnt[maxb] - cnt[i - 1]);
  cout << ans << endl;
  return 0;
}
