#include <bits/stdc++.h>
using namespace std;
long long powm(long long base, long long exp, long long mod = 1000000007) {
  long long ans = 1;
  while (exp) {
    if (exp & 1) ans = (ans * base) % mod;
    exp >>= 1, base = (base * base) % mod;
  }
  return ans;
}
void fastscan(int &x) {
  register int c = getchar();
  x = 0;
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
}
const int N = 2e5 + 5;
const int LOGN = 20;
long long down[N], depth[N], cities[N], timer, start[N], pa[N][LOGN];
vector<long long> adj[N];
void dfs(long long curr, long long prev, long long cnt) {
  pa[curr][0] = prev;
  depth[curr] = cnt;
  start[curr] = ++timer;
  for (auto child : adj[curr]) {
    if (child != prev) {
      dfs(child, curr, cnt + 1);
    }
  }
}
long long LCA(long long u, long long v) {
  if (depth[u] < depth[v]) swap(u, v);
  long long diff = depth[u] - depth[v];
  for (int i = 0; i < LOGN; i++) {
    if ((diff) & (1 << i)) u = pa[u][i];
  }
  if (u != v) {
    for (int i = LOGN - 1; i >= 0; i--) {
      if (pa[u][i] != pa[v][i]) {
        u = pa[u][i];
        v = pa[v][i];
      }
    }
    u = pa[u][0];
  }
  return u;
}
bool Comp(long long a, long long b) { return start[a] < start[b]; }
long long calc(long long a, long long b) {
  return depth[a] + depth[b] - 2 * depth[LCA(a, b)];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  for (int i = 0; i < 2 * k; i++) {
    cin >> cities[i];
  }
  for (int i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  memset(pa, -1, sizeof pa);
  dfs(1, 0, 0);
  for (int i = 0; i < LOGN; i++)
    for (int j = 1; j < n + 1; j++)
      if (pa[j][i] != -1) pa[j][i + 1] = pa[pa[j][i]][i];
  sort(cities, cities + 2 * k, Comp);
  long long ans = 0;
  for (int i = 0; i < k; i++) {
    ans += calc(cities[i], cities[i + k]);
  }
  cout << ans << endl;
}
