P8855 [POI 2002 R1] Business Trip.

Description

A merchant in the capital of a certain place often needs to travel to other towns for business, and he will follow his own route. There are $N$ towns, and the capital is numbered $1$. The merchant starts from the capital, and there are roads connecting the towns. If there is a direct road between any two towns, traveling between them costs one unit of time. Starting from the capital, it is possible to reach any town. Please find the merchant's shortest travel time.

Input Format

The first line contains an integer $N$, the number of towns. The next $N - 1$ lines each contain two integers $a$ and $b$, indicating that there is a road connecting town $a$ and town $b$. Next is an integer $M$, followed by $M$ lines. Each line contains the index of a town that the merchant needs to visit in order.

Output Format

Output one line containing the merchant's shortest travel time.

Explanation/Hint

Constraints: $1 \le N \le 30000$. **It is guaranteed that the road network contains no cycles.** Translated by ChatGPT 5