Double Kings

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

Our country is tree-like structure, that is to say that N cities is connected by exactly N - 1 roads.
The old king has two little sons. To make everything fairly, he dicided to divide the country into two parts and each son get one part. Two sons can choose one city as their capitals. For each city, who will be their king is all depend on whose capital is more close to them. If two capitals have the same distance to them, they will choose the elder son as their king. 
(The distance is the number of roads between two city)
The old king like his elder son more, so the elder son could choose his capital firstly. Everybody is selfish, the elder son want to own more cities after the little son choose capital while the little son also want to own the cities as much as he can.
If two sons both use optimal strategy, we wonder how many cities will choose elder son as their king.

Input

There are multiple test cases.
The first line contains an integer N (1 ≤ N ≤ 50000).
The next N - 1 lines each line contains two integers a and b indicating there is a road between city a and city b. (1 ≤ a, b ≤ N)

Output

For each test case, output an integer indicating the number of cities who will choose elder son as their king.

Sample Input

4 
1 2
2 3
3 4

4
1 2
1 3
1 4

Sample Output

2
3

Source

dut200901102

Manager

Information
Solved Number65
Submit Number139
Problem Tags
dfs and similar
No tag edit access
温馨提示:AC后可以编辑标签哦. ^-^
Login
LoginCancel