SP4197 DOMINOES - Dominoes

Description

Johnny is playing with some dominoes one afternoon. His dominoes come in a variety of heights and colors. Just like any other child, he likes to put them in a row and knock them over. He wants to know something: how many pushes does it take to knock down all the dominoes? Johnny is lazy, so he wants to minimize the number of pushes he takes. A domino, once knocked over, will knock over any domino that it touches on the way down. For the sake of simplicity, imagine the floor as a one-dimensional line, where 1 is the leftmost point. Dominoes will not slip along the floor once toppled. Also, dominoes do have some width: a domino of length 1 at position 1 can knock over a domino at position 2. For the mathematically minded: A domino at position _x_ with height _h_, once knocked over to the right, will knock all dominoes at positions _x_+1, _x_+2, ..., _x_+_h_ rightward as well. Similarly, the same domino knocked over to the left will knock all dominoes at positions _x_-1, _x_-2, ..., _x_-_h_ leftward.

Input Format

The input starts with a single integer _N_ (_N_ N pairs of integers. Each pair of integers represents the location and height of a domino, in that order (0 No two dominoes will have the same location.

Output Format

A single integer on a single line: the minimum number of pushes Johnny must make in order to ensure that all dominoes are knocked over.