G. Game on a Tree

Time limit: 2sMemory limit: 1024MBInput: Output:

Ana and Bob are playing a game on a tree with nn vertices.

First, two distinct vertices pp and qq are chosen, and the game starts with the simple path between them. The vertex pp is Ana's endpoint and qq is Bob's endpoint. The players then take turns, starting with Ana:

  • On her turn, Ana must choose a neighbor p′p' of pp that does not lie on the current path. The path is extended to p′p', and p′p' becomes Ana's new endpoint.
  • On his turn, Bob must choose a neighbor q′q' of qq that does not lie on the current path. The path is extended to q′q', and q′q' becomes Bob's new endpoint.

The player who cannot make a move loses.

Count the ordered pairs (p,q)(p, q) with p≠qp \ne q for which Ana wins, assuming both players play optimally.

Input

The first line contains a single integer nn (2≤n≤1062 \le n \le 10^6), the number of vertices in the tree.

Each of the next n−1n - 1 lines contains two integers uu and vv (1≤u,v≤n1 \le u, v \le n, u≠vu \ne v), meaning there is an edge between vertices uu and vv. It is guaranteed that the given edges form a tree.

Date de ieșire

Print a single integer: the number of ordered pairs (p,q)(p, q) for which Ana wins.

Example

stdin

5
1 3
2 3
4 3
5 1

stdout

6

Note

Ana wins for the following 66 pairs:

  • (1,2)(1, 2): the path is 1−3−21 - 3 - 2. Ana extends it to vertex 55. The only neighbor of 22 is 33, which is already on the path, so Bob cannot move.
  • (1,4)(1, 4): symmetric to the previous case.
  • (1,5)(1, 5): the path is 1−51 - 5. Ana extends it to vertex 33. The only neighbor of 55 is 11, which is already on the path, so Bob cannot move.
  • (3,2)(3, 2): the path is 3−23 - 2. Ana extends it to vertex 11 or 44, and Bob has no move from vertex 22.
  • (3,4)(3, 4): symmetric to the previous case.
  • (3,5)(3, 5): the path is 3−1−53 - 1 - 5. Ana extends it to vertex 22 or 44, and Bob has no move from vertex 55.

For example, Ana loses for (1,3)(1, 3). The path is 1−31 - 3, and Ana's only move is to vertex 55. Bob then extends the path to vertex 22. Ana's endpoint 55 has no neighbor outside the path, so she cannot move and loses.

Log In or Sign Up to be able to send submissions!