#include <bits/stdc++.h>
using namespace std;
long long suf(long long a) { return (a * (a + 1)) / 2; }
const long long OO = 1e6 + 10, S = 1e6 + 10;
vector<vector<int> > adj;
bool OK;
int dx[]{1, -1, 0, 0};
int dy[]{0, 0, 1, -1};
int dx8[]{1, -1, 0, 0, 1, -1, 1, -1};
int dy8[]{0, 0, 1, -1, 1, -1, -1, 1};
int main() {
  long long n, m, t, a, b, c, d;
  string s;
  while (cin >> n) {
    vector<int> v(S);
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
      v[a--] = b;
    }
    int mx = 0;
    for (int i = 0; i < v.size(); i++) {
      if (v[i] != 0 && i - v[i] - 1 >= 0)
        v[i] = v[i - v[i] - 1] + 1;
      else if (v[i] != 0)
        v[i] = 1;
      else if (i)
        v[i] += v[i - 1];
      mx = max(mx, v[i]);
    }
    cout << n - mx;
  }
  return 0;
}
