CSES - KILO 2018 2/5 - Counting Canals
  • Time limit: 2.00 s
  • Memory limit: 512 MB

Uolevi is visiting a foreign country with lots of tulips, windmills and of course, canals. Even on vacation Uolevi can't help but come up with tasks, and as such, he decided to count the number of canals in the country.

The country's waterways can be represented as a connected graph with nn nodes and n1n-1 edges (that is, as a tree).

Uolevi calls a path (a,b)(a, b) from node aa to node bb in this graph a canal, if the minimum index of any node on the path is aa, and the maximum index of any node on the path is bb.

Given the graph representing the waterways, output how many canals it contains. That is, output the number of ordered pairs (a,b)(a, b) such that the minimum index of a node on the path from aa to bb is aa, and the maximum index is bb.

With this definition, pairs (a,a)(a, a) are always counted once.

Input

The first line of input contains a single integer nn: the number of nodes.

After this, n1n-1 lines follow, the ii'th containing two integers aia_i and bib_i: nodes aia_i and bib_i are connected by an edge.

Output

Output a single integer: The number of canals.

Constraints

  • 1n1051 \leq n \leq 10^{5}
  • 1ai<bin1 \leq a_{i} < b_{i} \leq n

Example

Input:

5
1 2
2 3
3 4
4 5

Output:

15

Explanation:
All 15 pairs (a,b)(a, b) where aba \leq b are canals

Example 2

Input:

4
3 2
2 1
4 2

Output:

9

Explanation:
The canals are

(1 1), (1 2), (1 3), (1 4), (2 2),
(2 3), (2 4), (3 3), (4 4).