#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 1000 + 10;
const int maxn5 = 3 * 1000 * 100 + 10;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long inf = 1LL * 2 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;
int n, k, val[maxn5], h[maxn5];
bool mark[maxn5], uni[maxn5];
vector<int> adj[maxn5];
int dfs(int v) {
  mark[v] = true;
  int sum = 0;
  for (auto u : adj[v])
    if (!mark[u]) {
      h[u] = h[v] + 1;
      int a = dfs(u);
      sum += a;
      val[v] = max(val[v], a);
    }
  if (uni[v]) sum++;
  val[v] = max(val[v], k * 2 - sum);
  return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < k * 2; i++) {
    int a;
    cin >> a;
    uni[a] = true;
  }
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1);
  int v = 1;
  for (int i = 1; i <= n; i++)
    if (val[i] < val[v]) v = i;
  fill(mark, mark + maxn5, false);
  h[v] = 0;
  dfs(v);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (uni[i]) ans += h[i];
  cout << ans << endl;
  return 0;
}
