#include <bits/stdc++.h>
const int INF_INT = 0x3f3f3f3f;
const long long INF_LL = 0x7f7f7f7f;
const int MOD = 1e9 + 7;
const double eps = 1e-10;
const double pi = acos(-1);
using namespace std;
const int N = 200020;
int n, k;
vector<int> g[N];
int w[N];
int mx[N];
int sz[N];
int centroid;
void find(int fa, int u) {
  mx[u] = 0;
  sz[u] = w[u];
  for (auto& v : g[u]) {
    if (v == fa) continue;
    find(u, v);
    sz[u] += sz[v];
    mx[u] = max(mx[u], sz[v]);
  }
  mx[u] = max(mx[u], 2 * k - sz[u]);
  if (!centroid || mx[u] < mx[centroid]) centroid = u;
}
long long sum = 0;
void dfs(int fa, int u, int cnt) {
  if (w[u]) sum += cnt;
  for (auto& v : g[u]) {
    if (fa == v) continue;
    dfs(u, v, cnt + 1);
  }
}
int main(int argc, char const* argv[]) {
  scanf("%d%d", &n, &k);
  memset(w, 0, sizeof(w));
  for (int i = 1; i <= 2 * k; i++) {
    int x;
    scanf("%d", &x);
    w[x] = 1;
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  centroid = 0;
  find(-1, 1);
  sum = 0;
  dfs(-1, centroid, 0);
  cout << sum << endl;
  return 0;
}
