QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 10

#10383. Fuel [B]

الإحصائيات

In the good old days, all $ n $ towns in Byteland were connected by a dense network of two-way roads. The king of Byteland decided to reduce the number of roads, and asked his Chief Computer Scientist for advice. Now, as a result of this decision, Byteland has only $ n - 1 $ two-way roads connecting pairs of towns in such a way that there is exactly one route between any two towns in Byteland. All the roads are of the same length.

Equipped with a car whose tank has exactly enough fuel to drive on $ m $ roads in Byteland, Byteasar has decided to organize a trip that maximizes the number of visited towns. He can start his trip in any of the towns in Byteland, and, similarly, his trip can end anywhere-not necessarily back at the starting town. In maximizing the number of visited towns, Byteasar is allowed to drive multiple times on the same road, in the same or the reverse direction. Your task is to help Byteasar by finding the maximum number of towns that can be visited on one full tank of fuel.

Input Format

The first line of the input contains two integers, $ n $ and $ m $ ($2 \le n \le 500\,000$, $1 \le m \le 200\,000\,000$), where $ n $ is the number of towns in Byteland (each numbered uniquely from $\{1, \ldots, n \}$), and $ m $ is the number of roads that can be traveled on one tank of fuel.

The next $ n-1 $ lines describe Byteland's road network. Each of these lines contains two integers, $ a $ and $ b $ ($1 \le a , b \le n $), indicating that towns $ a $ and $ b $ are connected with a two-way road.

Output Format

The output consists of one line containing exactly one integer: the maximum number of towns that can be visited on one full tank of fuel.

Example

Input

7 6
1 2
2 3
2 5
5 6
5 7
4 5

Output

5

Byteasar can visit a maximum of five different towns. There are several different routes that visit five towns for this example input, including 4 → 5 → 7 → 5 → 6 → 5 → 2 and 3 → 2 → 1 → 2 → 5 → 6 → 5.

problem_10383_1.gif
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.