#include <bits/stdc++.h>
using namespace std;
const int N = 200011;
int n;
int in[N], Time;
const int LOGN = 32;
int dp[N][LOGN + 5], dep[N];
vector<int> gr[N];
vector<int> Kn;
void dfs_lca(int v, int p) {
  dp[v][0] = p;
  in[v] = ++Time;
  for (int i = 1; i <= LOGN; ++i) dp[v][i] = dp[dp[v][i - 1]][i - 1];
  dep[v] = dep[p] + 1;
  for (int i = 0; i < gr[v].size(); ++i) {
    int u = gr[v][i];
    if (u != p) dfs_lca(u, v);
  }
}
int LCA(int a, int b) {
  if (a == b) return a;
  if (dep[a] < dep[b]) swap(a, b);
  int diff = dep[a] - dep[b];
  int i = 0;
  while (i < LOGN) {
    if ((diff >> i) & 1) a = dp[a][i];
    ++i;
  }
  if (a == b) return a;
  i = LOGN;
  while (i >= 0) {
    if (dp[a][i] != dp[b][i]) a = dp[a][i], b = dp[b][i];
    i--;
  }
  return dp[a][0];
}
bool comp(const int &a, const int &b) { return in[a] < in[b]; }
int main() {
  int k;
  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = 0; i < 2 * k; ++i) {
    int kk;
    scanf("%d", &kk);
    Kn.push_back(kk);
  }
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d", &u), scanf("%d", &v);
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  dfs_lca(1, 0);
  sort(Kn.begin(), Kn.end(), comp);
  long long int ans = 0;
  for (int i = 0; i < k; ++i) {
    ans += (dep[Kn[i]] + dep[Kn[i + k]]) - 2 * dep[LCA(Kn[i], Kn[i + k])];
  }
  printf("%lld\n", ans);
  return 0;
}
