#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline void chmin(A &a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b) {
  if (a < b) a = b;
}
long long N, K;
long long lis[222222];
vector<long long> G[222222];
long long par[20][222222], dep[222222], sz[222222];
void dfs(long long v, long long p, long long d) {
  par[0][v] = p;
  dep[v] = d;
  for (auto u : G[v]) {
    if (p == u) continue;
    dfs(u, v, d + 1);
    sz[v] += sz[u];
  }
}
long long lca(long long u, long long v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (long long i = 0; i < (20); i++)
    if ((dep[u] - dep[v]) >> i & 1) u = par[i][u];
  if (u == v) return u;
  for (long long i = 19; i >= 0; i--)
    if (par[i][u] != par[i][v]) u = par[i][u], v = par[i][v];
  return par[0][u];
}
pair<long long, long long> findC(long long v, long long p) {
  pair<long long, long long> res(1001001001, -1);
  long long m = 0;
  for (auto u : G[v]) {
    if (u == p) continue;
    res = min(res, findC(u, v));
    m = max(m, sz[u]);
  }
  m = max(m, 2 * K - sz[v]);
  res = min(res, pair<long long, long long>(m, v));
  return res;
}
signed main() {
  scanf("%lld%lld", &N, &K);
  for (long long i = 0; i < (2 * K); i++)
    scanf("%lld", &lis[i]), lis[i]--, sz[lis[i]]++;
  for (long long i = 0; i < (N - 1); i++) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0, -1, 0);
  for (long long i = 0; i < (19); i++) {
    for (long long j = 0; j < (N); j++) {
      if (par[i][j] == -1)
        par[i + 1][j] = -1;
      else
        par[i + 1][j] = par[i][par[i][j]];
    }
  }
  long long c = findC(0, -1).second;
  long long ans = 0;
  for (long long i = 0; i < (2 * K); i++) {
    long long v = lis[i];
    long long p = lca(v, c);
    ans += dep[v] + dep[c] - 2 * dep[p];
  }
  cout << ans << endl;
  return 0;
}
