#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
int n, k, sum[N];
long long dp[N];
vector<int> eg[N];
void dfs(int u, int pre) {
  dp[u] = 0;
  for (int i = 0; i < eg[u].size(); i++) {
    int v = eg[u][i];
    if (v == pre) continue;
    dfs(v, u);
    sum[u] += sum[v];
    dp[u] += dp[v] + min(sum[v], k - sum[v]);
  }
}
int main() {
  int x, y;
  scanf("%d%d", &n, &k);
  k <<= 1;
  for (int i = 0; i < k; i++) {
    scanf("%d", &x);
    sum[x] = 1;
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    eg[x].push_back(y);
    eg[y].push_back(x);
  }
  dfs(1, -1);
  printf("%I64d\n", dp[1]);
  return 0;
}
