Dominoes (Large)

Find the fewest pushes (each a domino plus a direction) needed to topple every domino through chain reactions.

Hard8GreedySortingDynamic programmingIntervalsNo attempts yetTime limit1sMemory limit512 MB

Problem

NN dominoes stand on a number line. Domino ii stands at position XiX_i with height HiH_i, and no two dominoes share a position.

You may pick one domino and push it to the left or to the right. Pushing a domino at position xx with height hh to the left makes every domino at a position pp with xhpxx - h \le p \le x fall to the left. Pushing it to the right makes every domino at a position pp with xpx+hx \le p \le x + h fall to the right. A domino that falls this way keeps falling in the same direction and knocks over the dominoes inside its own range. The chain continues until no new domino falls.

Each push picks one domino and one direction. Compute the minimum number of pushes that knocks over all NN dominoes.

Input

The first line contains NN. (1N5000001 \le N \le 500\,000)

Each of the next NN lines contains two integers XiX_i and HiH_i, the position and the height of one domino, separated by a space. (1Xi,Hi20000000001 \le X_i, H_i \le 2\,000\,000\,000)

The dominoes are not necessarily given in order of position.

Output

Print the minimum number of pushes that knocks over every domino on the first line.