#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 20;
vector<int> e[N];
long long n, k, sz[N], ans;
void dfs(int u, int fa) {
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    if (v == fa) continue;
    dfs(v, u);
    ans += min(sz[v], 2 * k - sz[v]);
    sz[u] += sz[v];
  }
}
int main() {
  int u, v;
  while (cin >> n >> k) {
    ans = 0;
    for (int i = 1; i <= 2 * k; i++) scanf("%d", &u), sz[u]++;
    for (int i = 1; i <= n - 1; i++) {
      scanf("%d%d", &u, &v);
      e[u].push_back(v);
      e[v].push_back(u);
    }
    dfs(1, -1);
    printf("%I64d\n", ans);
  }
  return 0;
}
