Segments#5259

Segments

1 second
64 megabytes
Very easy

segments [a_i, b_i] are given on a coordinate line. Find the number of pairs such that i < j and segments [a_i, b_i] and [a_j, b_j] have at least one common point.

Input

The first line contains an integer (1 \le n \le 10^5). Each of the next lines contains numbers a_i and b_i — the end points of a corresponding segment (-10^9 \le a_i, b_i \le 10^9).

Output

Print the number of pairs of intersecting segments.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading