#include <bits/stdc++.h>
const int N = 2e5 + 10;
const int M = N << 1;
int n, m, k, head[N], to[M], nxt[M];
bool key[M];
long long ans, dp[N];
int cnt[N];
inline void Max(long long &a, long long b) {
  if (a < b) a = b;
}
inline void Max(int &a, int b) {
  if (a < b) a = b;
}
inline void add_edge(int a, int b) {
  to[m] = b;
  nxt[m] = head[a];
  head[a] = m++;
}
void dfs(int x, int fa) {
  dp[x] = 0;
  cnt[x] = key[x];
  for (int i = head[x]; ~i; i = nxt[i]) {
    int j = to[i];
    if (j == fa) continue;
    dfs(j, x);
    dp[x] = dp[x] + dp[j] + cnt[j];
    cnt[x] = cnt[x] + cnt[j];
  }
}
void dfs(int x, int fa, long long val, int C) {
  int mm = C;
  for (int i = head[x]; ~i; i = nxt[i]) {
    int j = to[i];
    if (j == fa) continue;
    Max(mm, cnt[j]);
    dfs(j, x, val + dp[x] - dp[j] - cnt[j] + C + cnt[x] - cnt[j],
        C + cnt[x] - cnt[j]);
  }
  if (mm <= k) {
    Max(ans, dp[x] + val);
  }
}
int main() {
  int x, y;
  while (~scanf("%d %d", &n, &k)) {
    for (int i = 1; i <= n; i++) {
      head[i] = -1;
      key[i] = 0;
    }
    m = 0;
    for (int i = 0; i < k * 2; i++) {
      scanf("%d", &x);
      key[x] = 1;
    }
    for (int i = 1; i < n; i++) {
      scanf("%d %d", &x, &y);
      add_edge(x, y);
      add_edge(y, x);
    }
    ans = 0;
    dfs(1, -1);
    dfs(1, -1, 0, 0);
    printf("%I64d\n", ans);
  }
  return 0;
}
