QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 16 MB Total points: 100

#11880. Cave

Statistics

There is a cave in Byteotia. It consists of $n$ chambers and corridors connecting them. The corridors are arranged in such way, that there is a unique path between each pair of chambers. In one of these chambers Hansel has hidden a treasure, but he won't tell which one it is. Gretel desires to know it. So she asks Hansel about various chambers. When she guesses right Hansel tells her she is right, and when she guesses wrong he tells her which way from this chamber leads to the treasure.

Write a programme that:

  • reads from the standard input the description of the cave,
  • finds the minimal number of questions Gretel has to ask in the worst case to learn in which chamber the treasure is hidden,
  • writes the result to the standard output.

Input

In the first line of the standard input there is one positive integer $n$, $1 ≤ n ≤ 50\,000$. It is the number of chambers in the cave. The chambers are numbered from $1$ to $n$. In the following $n-1$ lines the corridors linking the chambers are described, one per line. Each of these lines contains a pair of distinct positive integers $a$ and $b$ ($1 ≤ a,b ≤ n$), separated by a single space. It indicates that there is a corridor between chambers $a$ and $b$.

Output

Your programme should write one integer in the standard output, the minimal number of questions Gretel has to ask in the worst case (i.e. we assume Gretel asks the questions in the best possible way, but the treasure is hidden in the chamber that requires the largest number of questions).

Example

Input

5
1 2
2 3
4 3
5 3
problem_11880_1.gif

Output

2
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.