QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#6593. Little Q's Chessboard

統計

Little Q is designing a board game.

In Little Q's game, pieces can be placed on the grid points of a board. Some points are connected by lines, and a piece can only move between connected points. The entire board has $V$ points, labeled $0, 1, 2, \dots, V-1$. They are connected such that there is a unique path between any two points on the board. Little Q wants to ensure that when a piece starts from any point, it can reach any other point.

Little Q now wants to know: starting from point $0$, what is the maximum number of distinct points that can be visited in $N$ moves? Points can be visited multiple times, but they are only counted once.

Input

The first line contains two integers $V$ and $N$, where $V$ is the total number of points and $N$ is the number of moves.

The next $V-1$ lines each contain two integers $a_i, b_i$, representing a connection between point $a_i$ and point $b_i$.

Output

Output a single integer representing the maximum number of distinct points visited.

Examples

Input 1

5 2
1 0
2 1
3 2
4 3

Output 1

3

Note 1

Starting from point $0$, move $2$ steps. The path $0 \to 1 \to 2$ visits $3$ distinct points: $0, 1, 2$.

Input 2

9 5
0 1
0 2
2 6
4 2
8 1
1 3
3 7
3 5

Output 2

5

Note 2

One possible path is $0 \to 1 \to 3 \to 5 \to 3 \to 7$, which visits $5$ distinct points: $0, 1, 3, 5, 7$.

Constraints

For $100\%$ of the test cases, $V, N \le 100$, $0 \le a_i, b_i < V$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.