#584. 「Nowcoder多校 2019 Day4」meeting

「Nowcoder多校 2019 Day4」meeting

当前没有测试数据。

题目描述

A new city has just been built. There're nnn interesting places numbered by positive numbers from 1 1 to n n . In order to save resources, only exactly n1 n-1 roads are built to connect these nnn interesting places. Each road connects two places and it takes 1 second to travel between the endpoints of any road. There is one person in each of the places numbered x1,x2xk x1,x2…xk and they've decided to meet at one place to have a meal. They wonder what's the minimal time needed for them to meet in such a place. (The time required is the maximum time for each person to get to that place.)

输入格式

First line two positive integers, n,k n,k - the number of places and persons. For each the following n1 n−1 lines, there're two integers a,b a,b that stand for a road connecting place a a and b b . It's guaranteed that these roads connected all n n places. On the following line there're k k different positive integers x1,x2xk x1,x2…xk separated by spaces. These are the numbers of places the persons are at.

输出格式

A non-negative integer - the minimal time for persons to meet together.

样例

样例输入

4 2
1 2
3 1
3 4
2 4

样例输出

2

数据范围与提示

备注:

1n105 1 \leq n \leq 10^5

说明 They can meet at place 1 or 3.