#include <bits/stdc++.h>
using namespace std;
int n, l;
list<int> adjList[200005];
int depth[200002];
int sz[200002];
int timer;
vector<int> tin, tout;
vector<vector<int>> up;
vector<int> univ;
set<int> ks;
void dfs(int v, int p) {
  tin[v] = ++timer;
  up[v][0] = p;
  for (int i = 1; i <= l; ++i) up[v][i] = up[up[v][i - 1]][i - 1];
  for (int u : adjList[v]) {
    if (u != p) dfs(u, v);
  }
  tout[v] = ++timer;
}
bool is_ancestor(int u, int v) {
  return tin[u] <= tin[v] && tout[u] >= tout[v];
}
int lca(int u, int v) {
  if (is_ancestor(u, v)) return u;
  if (is_ancestor(v, u)) return v;
  for (int i = l; i >= 0; --i) {
    if (!is_ancestor(up[u][i], v)) u = up[u][i];
  }
  return up[u][0];
}
void preprocess(int root) {
  tin.resize(n + 3);
  tout.resize(n + 3);
  timer = 0;
  l = ceil(log2(n));
  up.assign(n + 3, vector<int>(l + 1));
  dfs(root, root);
}
int deep(int i, int p, int d) {
  depth[i] = d++;
  if (ks.count(i)) univ.push_back(i);
  sz[i] = 1;
  for (int v : adjList[i])
    if (v != p) sz[i] += deep(v, i, d);
  return sz[i];
}
int main() {
  int k;
  cin >> n >> k;
  for (int i = 0; i < k << 1; i++) {
    int(p);
    scanf("%d", &(p));
    ks.insert(p);
  }
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    adjList[a].push_back(b);
    adjList[b].push_back(a);
  }
  preprocess(1);
  deep(1, 0, 0);
  long long ans = 0LL;
  for (int i = 0; i < k; i++)
    ans += (long long)(depth[univ[i]] + depth[univ[i + k]] -
                       (depth[lca(univ[i], univ[i + k])] << 1));
  cout << ans << "\n";
  return 0;
}
