#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, dp[N];
long long ans;
vector<int> g[N];
void dfs1(int v, int pr = -1, int d = 0) {
  if (dp[v]) {
    ans += d;
  }
  for (int to : g[v]) {
    if (to != pr) {
      dfs1(to, v, d + 1);
      dp[v] += dp[to];
    }
  }
}
void dfs2(int v, int pr = -1, int cur = 0, int d = 0) {
  int sum = dp[v] - cur, mx = -1e9;
  for (int to : g[v]) {
    if (to != pr) {
      mx = max(mx, dp[to] - cur);
    }
  }
  if (mx * 2 > sum) {
    ans -= 2ll * d * (sum - mx);
    for (int to : g[v]) {
      if (to != pr && mx == dp[to] - cur) {
        dfs2(to, v, cur + sum - mx, d + 1);
      }
    }
  } else {
    ans -= 1ll * d * (dp[v] - cur);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m * 2; i++) {
    int x;
    cin >> x;
    dp[x] = 1;
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs1(1);
  dfs2(1);
  cout << ans;
}
