题目描述
Problem Description
There is a tree with $ N $ vertices. Each vertex in the tree is numbered from $ 1 $ to $ N $.
There are $ N-1 $ edges, and the $ i $-th edge connects vertex $ p_i $ and vertex $ q_i $.
Find the maximum $ M $ of a sequence of distinct vertices $ v_1, v_2, ..., v_M $ that satisfies the following condition:
- For all $1 \leq i < M$, there is no other vertex on the path connecting $ v_i $ and $ v_{i+1} $.
Input Format
The input is given from the standard input in the following format:
$ N $ $ p_1 $ $ q_1 $ $ p_2 $ $ q_2 $ $ : $ $ p_{N-1} $ $ q_{N-1} $
Output Format
Output the maximum $ M $ of the sequence of distinct vertices that satisfies the condition.
Sample Input and Output
Sample Input #1
4
1 2
2 3
2 4
Sample Output #1
3
Sample Input #2
10
7 9
1 2
6 4
8 1
3 7
6 5
2 10
9 6
2 6
Sample Output #2
8
Notes/Hints
Constraints
- $2 \leq N \leq 10^5$
- $1 \leq p_i, q_i \leq N$
- The given graph is a tree.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分
样例输入
4
1 2
2 3
2 4
样例输出
3