All the buildings in the eastern district of Byteburg were built in the old style: they stand right next to one another with no gaps in between. Together they form a very long chain of buildings of varying heights, stretching from east to west.
The mayor of Byteburg, Byteasar, has decided to cover the northern face of the chain with posters. He wonders about the smallest number of posters that suffices to cover the whole northern face. Each poster is a rectangle with vertical and horizontal sides. Posters may not overlap, but they may touch, that is, share points along their edges. Every poster must lie flush against the walls of some buildings, and the entire surface of the northern face must be covered.
Write a program that:
The first line contains one integer n (1≤n≤250000), the number of buildings in the chain. Each of the next n lines contains two integers di and wi (1≤di,wi≤109), separated by a single space, giving respectively the width and the height of the i-th building in the row.
Output a single integer: the minimum number of rectangular posters that suffice to cover the northern faces of the buildings.
The figures below illustrate an example. The first shows the northern face of a chain of buildings, and the second shows one way to cover that face with four posters.

