A city reports n road closures along a single street, each given as a range [start_i, end_i] measured in meters from the start of the street. Closures may overlap or touch each other. Print the total length (in meters) of street that is covered by at least one closure, i.e. the length of the union of all the given ranges.
Input format
Line 1: an integer n.
Next n lines: two integers start_i end_i describing closure i.
Output format
A single integer: the total length of street covered by at least one closure.
Constraints
- 1 <= n <= 40
- 0 <= start_i < end_i <= 1000