#include <bits/stdc++.h>
using namespace std;
vector<int> graph[200000 + 5];
bool visited[200000 + 5];
bool isGood[200000 + 5];
int countGood[200000 + 5];
int n, k;
long long int ans = 0;
void dfs(int u) {
  visited[u] = true;
  countGood[u] = 0;
  if (isGood[u]) {
    countGood[u]++;
  }
  for (auto v : graph[u]) {
    if (!visited[v]) {
      dfs(v);
      countGood[u] += countGood[v];
    }
  }
  ans += min(2 * k - countGood[u], countGood[u]);
}
int main() {
  int i, j, u, v, sum = 0;
  scanf("%d %d", &n, &k);
  for (i = 1; i <= 2 * k; i++) {
    scanf("%d ", &u);
    isGood[u] = true;
  }
  for (i = 1; i <= n - 1; i++) {
    scanf("%d %d", &u, &v);
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  dfs(1);
  cout << ans;
  return 0;
}
