#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> e;
vector<bool> f;
vector<int> s;
int size(int u = 1, int p = 0) {
  int& ans = s[u];
  if (ans < 0) {
    ans = f[u] ? 1 : 0;
    for (int v : e[u])
      if (v != p) ans += size(v, u);
  }
  return ans;
}
long long solve(int r = 0, int u = 1, int p = 0) {
  long long ans = r;
  if (r == size(u)) {
    for (int v : e[u])
      if (v != p) ans += solve(size(v), v, u);
  } else {
    if (f[u]) r++;
    priority_queue<pair<int, int>> PQ;
    PQ.push(pair<int, int>(0, p));
    for (int v : e[u])
      if (v != p) PQ.push(pair<int, int>(size(v), v));
    for (int i = 0; i < r;) {
      pair<int, int> D = PQ.top();
      PQ.pop();
      int d = max(min(r - i, D.first - PQ.top().first), 1);
      D.first -= d;
      ;
      i += d;
      PQ.push(D);
    }
    if (PQ.top().first * 2 > (size(u) - r - (f[u] ? 1 : 0))) {
      const pair<int, int>& D = PQ.top();
      ans += solve(
          size(D.second) - D.first + (size(u) - r - (f[u] ? 1 : 0)) - (D.first),
          D.second, u);
      PQ.pop();
    }
    for (; !PQ.empty(); PQ.pop()) {
      const pair<int, int>& D = PQ.top();
      if (D.second != p) ans += solve(size(D.second), D.second, u);
    }
  }
  return ans;
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  k <<= 1;
  e.resize(n + 1);
  f.assign(n + 1, false);
  s.assign(n + 1, -1);
  for (int i = 0; i < k; i++) {
    int x;
    scanf("%d", &x);
    f[x] = true;
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  printf("%I64d\n", solve());
}
