#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
vector<int> e[maxn];
int n, k, x, y;
int a[maxn];
int cnt[maxn], counter, depth[maxn];
int f[19][maxn];
void dfs1(int now, int prev, int d) {
  cnt[now] = counter++;
  depth[now] = d;
  f[0][now] = prev;
  for (auto t : e[now]) {
    if (t == prev) continue;
    dfs1(t, now, d + 1);
  }
}
int lca(int a, int b) {
  if (depth[a] < depth[b]) swap(a, b);
  int len = depth[a] - depth[b];
  for (int i = 0; i < 19; i++) {
    if (len & (1 << i)) {
      a = f[i][a];
    }
  }
  if (a != b) {
    for (int i = 18; i >= 0; i--) {
      if (f[i][a] != f[i][b]) {
        a = f[i][a];
        b = f[i][b];
      }
    }
    a = f[0][a];
  }
  return a;
}
int dis(int a, int b) { return depth[a] + depth[b] - 2 * depth[lca(a, b)]; }
bool cmp(int a, int b) { return cnt[a] < cnt[b]; }
void solve() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k * 2; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs1(1, 0, 1);
  for (int i = 1; i < 19; i++) {
    for (int j = 1; j <= n; j++) f[i][j] = f[i - 1][f[i - 1][j]];
  }
  sort(a, a + 2 * k, cmp);
  long long res = 0;
  for (int i = 0; i < k; i++) {
    res = res + dis(a[i], a[i + k]);
  }
  printf("%I64d\n", res);
}
int main() {
  solve();
  return 0;
}
