Chain Reaction

There are n beacons located at distinct positions on a number line. The i-th beacon has position a i and power level b i. When the i-th beacon is activated, it destroys all beacons to its left (direction of decreasing coordinates) within distance b i inclusive. The beacon itself is not destroyed however. Saitama will activate the beacons one at a time from right to left. If a beacon is destroyed, it cannot be activated.

Saitama wants Genos to add a beacon strictly to the right of all the existing beacons, with any position and any power level, such that the least possible number of beacons are destroyed. Note that Genos’s placement of the beacon means it will be the first beacon activated. Help Genos by finding the minimum number of beacons that could be destroyed.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 100 000) — the initial number of beacons.

The i-th of next n lines contains two integers a i and b i (0 ≤ a i ≤ 1 000 000, 1 ≤ b i ≤ 1 000 000) — the position and power level of the i-th beacon respectively. No two beacons will have the same position, so a i ≠ a j if i ≠ j.

Output

Print a single integer — the minimum number of beacons that could be destroyed if exactly one beacon is added.

Examples

input

4
1 9
3 1
6 1
7 4

output

1

input

7
1 1
2 1
3 1
4 1
5 1
6 1
7 1

output

3

Note

For the first sample case, the minimum number of beacons destroyed is 1. One way to achieve this is to place a beacon at position 9 with power level 2.

For the second sample case, the minimum number of beacons destroyed is 3. One way to achieve this is to place a beacon at position 1337 with power level 42.

Solution:

#include <bits/stdc++.h>

using namespace std;

const int N = 1234567;

int f[N], nxt[N];
pair <int, int> a[N];

int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first, &a[i].second);
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    int low = -1, high = i - 1;
    while (low < high) {
      int mid = low + (high - low + 1) / 2;
      if (a[mid].first < a[i].first - a[i].second) {
        low = mid;
      } else {
        high = mid - 1;
      }
    }
    nxt[i] = low;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    f[i] = 1 + (nxt[i] >= 0 ? f[nxt[i]] : 0);
ans = max(ans, f[i]);
}
printf("%d\n", n - ans);
return 0;
}