#include <bits/stdc++.h>
using namespace std;
const long long N = 400005;
long long n, m, x, y, t, ans, a[N], cnt[N], head[N];
struct node {
  long long too, Next;
} edge[N];
void add(long long a, long long b) {
  edge[++t].too = b;
  edge[t].Next = head[a];
  head[a] = t;
}
void dfs(long long u, long long fa) {
  cnt[u] = a[u];
  for (long long i = head[u]; i; i = edge[i].Next) {
    long long v = edge[i].too;
    if (v == fa) continue;
    dfs(v, u);
    ans += min(cnt[v], 2 * m - cnt[v]);
    cnt[u] += cnt[v];
  }
}
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= 2 * m; i++) {
    scanf("%lld", &x);
    a[x] = 1;
  }
  for (long long i = 1; i < n; i++) {
    scanf("%lld%lld", &x, &y);
    add(x, y);
    add(y, x);
  }
  dfs(1, 0);
  printf("%lld\n", ans);
  return 0;
}
