LearnPy Hub
← Arena
AdvancedRating 1500

Longest Path in a Tree

Print the number of edges on the longest path between any two nodes of the tree.

Input

n; then n − 1 lines 'u v'.

Output

One integer.

Sample 1

Input
5
1 2
1 3
2 4
2 5
Output
3

Sample 2

Input
1
Output
0
solution.py
Output appears here
Longest Path in a Tree · Python Arena problem · LearnPy Hub