Capital Program
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

There is a kingdom that has n cities connected by n-1 roads. All roads' length is 1. The King wants to choose an area to be the capital of the kingdom. The area must have exactly k connected cities (the area of the capital is a connected component with exactly k cities). To show the importance of the capital, the King wants to minimize the maximum value of all the n cities.
We define the value of a city as the minimum distance between the city and one city which belongs to the capital. The distance between two cities is the length of the shortest path between them.

输入描述:

The first line of each test contains two integers  and  () --- the number of vertices and the number of cities of the capital, respectively.

Next  lines describe edges: the -th line contains two integers  () --- indices of vertices connected by the -th edge.

输出描述:

Print the minimum of the maximum value of all cities.
示例1

输入

复制
6 3
1 2
2 3
2 4
1 5
5 6

输出

复制
1