#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 100;
const int INF = 1e9 + 7;
int cnt[MAXN + 1];
int sum[MAXN + 1];
int get(int l, int r) { return sum[r + 1] - sum[l]; }
vector<int> v[MAXN + 1];
int dp[MAXN + 1];
int a[MAXN + 1];
int b[MAXN + 1];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    v[a[i]].push_back(a[i] - b[i]);
    cnt[a[i]]++;
  }
  sum[0] = 0;
  for (int i = 1; i <= MAXN; i++) sum[i] = sum[i - 1] + cnt[i - 1];
  dp[0] = max(0, int(v[0].size()) - 1);
  for (int i = 1; i < MAXN; i++) {
    if (int(v[i].size()) == 0)
      dp[i] = dp[i - 1];
    else {
      int num = i;
      for (int j = 0; j < int(v[i].size()); j++)
        num = min(num, max(0, v[i][j]));
      if (num != 0)
        dp[i] = dp[num - 1] + get(num, i) - 1;
      else
        dp[i] = get(num, i) - 1;
    }
  }
  int answer = n;
  for (int i = 0; i < MAXN - 1; i++) {
    int cur = dp[i] + get(i + 1, MAXN - 1);
    answer = min(answer, cur);
  }
  cout << answer << endl;
  return 0;
}
