#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, k, C[N];
long long tot;
vector<int> Adj[N];
void DFS(int v, int p) {
  for (auto X : Adj[v])
    if (X != p) DFS(X, v), C[v] += C[X];
  tot += min(C[v], k + k - C[v]);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0, v; i < k + k; i++) scanf("%d", &v), C[v]++;
  for (int i = 1, v, u; i < n; i++)
    scanf("%d%d", &v, &u), Adj[v].push_back(u), Adj[u].push_back(v);
  DFS(1, 0);
  return !printf("%lld", tot);
}
