F. Fun Tournament
time limit per test
4 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Womais is hosting a Smash Tournament and is trying to pick two contestants to participate in a showmatch! In this showmatch, the two chosen contestants will play two separate sets against each other.

Each of the $$$n$$$ contestants has two playstyles that they want to show off – $$$a_i$$$ and $$$b_i$$$. If picked to play in the showmatch, they will use style $$$a_i$$$ in the first set and style $$$b_i$$$ in the second set.

In a given set, if the two contestants use styles $$$u$$$ and $$$v$$$ respectively, then the $$$\textit{character}$$$ of that set can be calculated as $$$\left|u - v\right|$$$.

Womais knows that if the two sets have the same $$$\textit{character}$$$, then the viewers will get bored and leave the event. On the other hand, if the two sets have different $$$\textit{character}$$$, then the match is guaranteed to be interesting.   Find the number of pairs of contestants Womais can choose to produce an interesting match!

Input

The first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 3\cdot 10^5$$$) – The number of potential contestants. The next $$$n$$$ lines contain two integers, $$$a_i, b_i$$$ ($$$1 \leq a_i, b_i \leq 10^9$$$) – The styles the $$$i$$$-th contestant will use in the first and second sets respectively.

Output

Output a single integer – the number of pairs of contestants who will produce an interesting match.

Example
Input
5
12 17
15 20
8 23
23 8
15 20
Output
6