AT_past20_l 直径のペア

Description

You are given a tree with $ N $ vertices. The $ i $ -th edge connects vertices $ A_i $ and $ B_i $ . The distance between two vertices $ x $ and $ y $ on the tree is the minimum possible number of edges in a path from $ x $ to $ y $ . The diameter of the tree is the maximum distance between two vertices. Let $ D $ be the diameter of this tree. Find the number of pairs of vertices $ (a, b) \ (a < b) $ such that the distance between $ a $ and $ b $ equals $ D $ .

Input Format

The input is given from Standard Input in the following format: > $ N $ $ A_1 $ $ B_1 $ $ A_2 $ $ B_2 $ $ \vdots $ $ A_{N-1} $ $ B_{N-1} $

Output Format

Print the answer in a single line.

Explanation/Hint

### Sample Explanation 1 The diameter of this tree is $ 3 $ . The pairs of vertices distant by $ 3 $ are $ (2, 5) $ and $ (3, 5) $ . Thus, `2` should be printed. ### Constraints - $ 1 \leq N \leq 2 \times 10^5 $ - $ 1 \leq A_i, B_i \leq N $ - The given graph is a tree.