Given a tree with n nodes (numbered 0 to n-1) and n-1 edges, you may add exactly one edge between any two nodes to create a cycle. Return the length of the longest cycle that can be formed (number of nodes in the cycle).
Input
n: number of nodes
edges: array of [u, v] pairs describing the tree's edges
Output
The length of the longest possible cycle after adding one edge.
Examples
Example 1
Inputn = 4, edges = [[0, 1], [1, 2], [2, 3]]
Output4
Example 2
Inputn = 2, edges = []
Output1
Constraints
1 <= n <= 10^5.
edges describes a tree (connected, n-1 edges, no cycles).