P24806 [AtCoder] [ABC368D] Minimum Steiner Tree
普及
题目描述

Problem Description

Given a tree with $ N $ vertices numbered from $ 1 $ to $ N $. The $ i $ -th edge connects vertex $ A_i $ and vertex $ B_i $.

From this graph, remove some (possibly zero) edges and vertices to form a tree that includes all the specified $ K $ vertices, $V_1, \ldots, V_K$. Find the minimum number of vertices in such a tree.

Input Format

The input is given from the standard input in the following format:

$ N $ $ K $ $ A_1 $ $ B_1 $ $\vdots$ $ A_{N-1} $ $ B_{N-1} $ $ V_1 $ $\ldots$ $ V_K $

Output Format

Output the answer.

Sample Input and Output

Sample Input #1

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

Sample Output #1

4

Sample Input #2

4 4
3 1
1 4
2 1
1 2 3 4

Sample Output #2

4

Sample Input #3

5 1
1 4
2 3
5 2
1 2
1

Sample Output #3

1

Notes/Hints

Constraints

  • $1 \leq K \leq N \leq 2 \times 10^5$
  • $1 \leq A_i, B_i \leq N$
  • $1 \leq V_1 < V_2 < \ldots < V_K \leq N$
  • The given graph is a tree.
  • All inputs are integers.

Sample Explanation 1

The given tree is as shown in the left diagram below, and the tree with the minimum number of vertices that includes all vertices $ 1, 3, 5 $ is as shown in the right diagram.

図

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
7 3 1 2 1 3 2 4 2 5 3 6 3 7 1 3 5
样例输出
4