#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n, k, a[N], g[N], v[N * 2], nxt[N * 2], ed, x, y, son[N], zhong,
    zmx = 1 << 29;
long long ans = 0;
inline void adg(int x, int y) { v[++ed] = y, nxt[ed] = g[x], g[x] = ed; }
void dfs(int x = 1, int pre = 1) {
  son[x] = a[x];
  int mx = 0;
  for (int i = g[x]; i; i = nxt[i])
    if (v[i] != pre) dfs(v[i], x), son[x] += son[v[i]], mx = max(mx, son[v[i]]);
  mx = max(mx, 2 * k - son[x] + 1);
  if (zmx > mx) zhong = x, zmx = mx;
}
void find(int x = zhong, int pre = zhong, int dis = 0) {
  if (a[x]) ans += dis;
  for (int i = g[x]; i; i = nxt[i])
    if (v[i] != pre) find(v[i], x, dis + 1);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= k << 1; ++i) scanf("%d", &x), a[x] = 1;
  for (int i = 1; i <= n - 1; ++i) scanf("%d%d", &x, &y), adg(x, y), adg(y, x);
  dfs(), find(), printf("%I64d\n", ans);
  return 0;
}
