#include <bits/stdc++.h>
using namespace std;
const int maxn = 200200;
int head[maxn], siz[maxn];
int to[maxn << 1], NEXT[maxn << 1];
bool p[maxn];
int n, k, cnt = 1;
void insert(int u, int v) {
  to[++cnt] = v;
  NEXT[cnt] = head[u];
  head[u] = cnt;
  to[++cnt] = u;
  NEXT[cnt] = head[v];
  head[v] = cnt;
}
void dfs(int u, int f) {
  if (p[u]) siz[u] = 1;
  for (int i = head[u], v = to[i]; i; i = NEXT[i], v = to[i])
    if (v != f) {
      dfs(v, u);
      siz[u] += siz[v];
    }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < 2 * k; i++) {
    int u;
    scanf("%d", &u);
    p[u] = 1;
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    insert(u, v);
  }
  dfs(1, 0);
  long long ans = 0;
  for (int i = 1; i < n + 1; i++) ans += min(siz[i], 2 * k - siz[i]);
  printf("%lld\n", ans);
  return 0;
}
