#include <bits/stdc++.h>
#pragma warning(disable : 4786)
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int maxn = 2e5 + 5;
int isu[maxn], sz[maxn], dis[maxn], kk;
long long ans;
vector<int> G[maxn];
void dfs1(int root, int fa, long long depth) {
  int siz = G[root].size(), nt;
  dis[root] = depth;
  if (isu[root]) {
    sz[root] = 1;
    ans += depth;
  }
  for (int i = 0; i < siz; i++) {
    nt = G[root][i];
    if (nt == fa) continue;
    dfs1(nt, root, depth + 1LL);
    sz[root] += sz[nt];
  }
}
void solve(int root, int fa) {
  if (kk <= 0) return;
  priority_queue<pair<int, int> > Q;
  int siz = G[root].size(), nt;
  for (int i = 0; i < siz; i++) {
    nt = G[root][i];
    if (nt == fa) continue;
    if (sz[nt] > 0) {
      Q.push(make_pair(sz[nt], nt));
    }
  }
  if (isu[root]) {
    Q.push(make_pair(1, root));
  }
  pair<int, int> f1 = Q.top(), f2;
  int fir = f1.first, sec = f1.second, sum = 0;
  if (Q.size() == 1) {
    solve(sec, root);
  } else {
    Q.pop();
    while (!Q.empty()) {
      f2 = Q.top();
      Q.pop();
      sum += f2.first;
    }
    sum = min(sum, kk);
    kk -= sum;
    ans -= 2LL * dis[root] * sum;
    if (kk > 0) solve(sec, root);
  }
}
int main() {
  int n, k, x, y;
  scanf("%d %d", &n, &k);
  kk = k;
  for (int i = 1; i <= 2 * k; i++) {
    scanf("%d", &x);
    isu[x] = 1;
  }
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  ans = 0;
  dfs1(1, 0, 0);
  solve(1, 0);
  printf("%lld\n", ans);
  return 0;
}
