Byteburg University runs a climbing course. Up to 2n students can take part at the same time. Each climber has their own separate route and can move up or down along it. The climbers are split into n pairs; the two climbers in a pair stand on adjacent routes and hang from the same belay rope. Every rope is fixed at the top of the wall at a point between two routes and must stay tense at all times.
The length of each rope is no greater than the height of the wall. Once one climber in a pair reaches the top of the wall, the other climber in that pair can no longer move downward.

Figure: a pair of climbers hanging from a single rope.
Except for the leftmost and rightmost climbers, every climber has exactly one neighbor to the left and one to the right; the two climbers at the ends have a single neighbor. The instructor gives the students an exercise: adjust the heights so that the number of pairs of adjacent climbers from different ropes hanging at the same height is as large as possible. Find the maximum possible number of such adjacent pairs.
The first line contains an integer n (1≤n≤50000), the number of pairs of climbers. Each of the next n lines describes one pair, given from left to right. Each line contains two integers a and b (0≤a,b≤109), the distances of the two climbers in that pair from the point where their rope is fixed.
Print a single integer: the maximum number of adjacent pairs of climbers from different ropes that can be aligned at the same height.
