A room's reservations are given as n half-open intervals [start, end). Merge any two reservations that overlap or touch (share an endpoint) into a single continuous block, repeating until no more merges are possible. Report the number of resulting blocks.
Input format
Line 1: an integer n.
Next n lines: two integers start end (with start < end).
Output format
A single integer: the number of merged blocks.
Constraints
- 1 ≤ n ≤ 100000
- 0 ≤ start < end ≤ 1000000