#include <bits/stdc++.h>
typedef struct beacon {
  int state;
  int power;
} Beacon;
Beacon B[1000001], C[1000001];
int fun(int index[], int lower, int higher, int val) {
  int low, high, mid, i, lastmid;
  low = lower;
  high = higher;
  while (low <= high) {
    lastmid = mid;
    mid = (high - low) / 2 + low;
    if (index[mid] < val)
      low = mid + 1;
    else if (index[mid] > val)
      high = mid - 1;
    else
      break;
  }
  if (index[mid] <= val)
    return mid;
  else
    return mid - 1;
}
int cmp(const void *a, const void *b) { return *(int *)a > *(int *)b ? 1 : -1; }
int main() {
  int i, j, min, in, cnt, num, k;
  for (i = 1; i < 1000001; i++) {
    B[i].state = -1;
  }
  int n;
  scanf("%d", &n);
  min = n;
  int Index[n + 1], boom[n + 1], boommax;
  for (i = 1; i <= n; i++) {
    int index;
    scanf("%d", &index);
    B[index].state = 1;
    scanf("%d", &B[index].power);
    Index[i] = index;
  }
  boom[1] = 0;
  Index[0] = -1;
  qsort(Index, n + 1, sizeof(Index[0]), cmp);
  for (i = 2; i <= n; i++) {
    int lastindex = Index[i] - B[Index[i]].power;
    if (lastindex <= 0)
      boom[i] = i - 1;
    else {
      int last = fun(Index, 1, i, lastindex - 1);
      boom[i] = boom[last] + i - last - 1;
    }
  }
  for (i = 1; i <= n; i++) {
    int boomnum = n - i;
    boomnum += boom[i];
    if (boomnum < min) min = boomnum;
  }
  printf("%d", min);
}
