401369: GYM100418 I Pair of paths
Description
The kingdom has N castles numbered from 1 to N. The castles are connected with N - 1 roads. The road construction takes a huge amount of money, that's why thrifty inhabitants of the kingdom decided to plan the kingdom in such way that between every pair of castles there is exactly one path. Two brave knights independently start their journeys. Each knight randomly selects two castles where he starts and also finishes his trip. Then he goes through the kingdom by the shortest possible path and writes down all numbers of castles that he visits to his own list. After that they go to the chronicler and give him two lists of the castles which they have visited. And if there is no such castle which was visited by both knights, the chronicler will write to the annals that this pair of journeys was epic. Your goal is to find the number of existing different epic journeys pairs.
InputAt the first line N — number of castles in the kingdom (1 ≤ N ≤ 105). At the next N - 1 lines Ai Bi — roads between castles.
OutputSingle line containing the number of existing different epic journeys.
ExamplesInput6Output
1 2
1 3
2 4
2 5
3 6
12