#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const int N = 200100;
int n, k, p[N];
int dis[N];
bool is[N];
vector<int> adj[N];
int sz[N];
void dfs(int u, int par = 0) {
  dis[u] = dis[par] + 1;
  for (auto v : adj[u]) {
    if (v == par) continue;
    dfs(v, u);
  }
  return;
}
void dfs1(int u, int p) {
  sz[u] = (is[u]);
  for (auto v : adj[u]) {
    if (v != p) {
      dfs1(v, u);
      sz[u] += sz[v];
    }
  }
}
int dfs2(int u, int cnt = sz[1], int p = 0) {
  for (auto v : adj[u]) {
    if (v != p)
      if (2 * sz[v] >= cnt) return dfs2(v, cnt, u);
  }
  return u;
}
int main() {
  scanf("%d %d", &n, &k);
  k *= 2;
  vector<int> sp(k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &(sp[i - 1]));
    is[sp[i - 1]] = 1;
  }
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs1(1, 0);
  int cen = dfs2(1);
  dis[0] = -1;
  dfs(cen, 0);
  long long ANS = 0;
  for (auto x : sp) {
    ANS += dis[x];
  }
  printf("%lld\n", ANS);
  return 0;
}
