#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<bool> U;
vector<int> C;
vector<vector<int> > E;
int dfs0(int cur, int pre) {
  int ret = U[cur];
  for (auto&& nex : E[cur]) {
    if (nex != pre) {
      ret += dfs0(nex, cur);
    }
  }
  C[cur] = ret;
  return ret;
}
long long ans = 0;
void dfs(int cur, int pre) {
  for (auto&& nex : E[cur]) {
    if (nex != pre) {
      int cnex = C[nex];
      ans += min(cnex, 2 * K - cnex);
      dfs(nex, cur);
    }
  }
}
void Main() {
  scanf("%d%d", &N, &K);
  U.resize(N);
  E.resize(N);
  C.resize(N);
  for (int i = int(0); i < int(K * 2); ++i) {
    int u;
    scanf("%d", &u);
    U[u - 1] = 1;
  }
  for (int i = int(0); i < int(N - 1); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    E[u].push_back(v);
    E[v].push_back(u);
  }
  dfs0(0, -1);
  dfs(0, -1);
  (void)printf("%lld\n", ans);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  Main();
  return 0;
}
