A rancher lays n fence strips along a straight fence line. Each strip is a closed segment [start, end] (a strip with start == end is a single post). Two strips belong to the same block if they share at least one point — that is, they overlap or touch at an endpoint. Sharing is transitive: if strip A shares a point with B and B with C, then A, B and C form one block. Count the number of separate blocks.
Input format
Line 1: an integer n.
Next n lines: two integers start and end describing one strip.
Output format
A single integer: the number of separate blocks after joining.
Constraints
- 1 ≤ n ≤ 100000
- 0 ≤ start ≤ end ≤ 1000000000