#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 212;
bool is[N];
vector<int> g[N];
int nu[N], h[N], root;
long long ans;
int dfs(int v, int p = 0, int depth = 0) {
  h[v] = depth;
  int num = 0;
  for (int u : g[v])
    if (u != p) num += (nu[u] = dfs(u, v, depth + 1));
  return num + is[v];
}
void rec(int v, int k, int p, int s) {
  int x, num = 0;
  for (int u : g[v]) {
    if (u == p) continue;
    if (nu[u] > k) {
      rec(u, k, v, s + (nu[v] - nu[u]));
      return;
    }
  }
  root = v;
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < 2 * k; i++) {
    int x;
    cin >> x;
    is[x] = 1;
  }
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  nu[1] = dfs(1);
  rec(1, k, 0, 0);
  nu[1] = dfs(root);
  for (int i = 1; i <= n; i++) ans += 1LL * is[i] * h[i];
  cout << ans;
  return 0;
}
