#include <bits/stdc++.h>
using namespace std;
const long long MAX = 2500000000;
const int inf = 0x3f3f3f3f;
const double EPS = 1e-9;
const double PII = 2 * asin(1.0);
const long long mod = 100000007;
int double_cmp(double x, double y = 0, double tol = EPS) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
const int maxn = 200010;
bool has_uni[maxn];
vector<int> adj[maxn];
int contador[maxn], alt[maxn];
int n, k, esc;
void dfs_alt(int v, int h, int pai) {
  alt[v] = h;
  int cont = has_uni[v];
  bool pode = true;
  for (int i = 0; i < ((int)adj[v].size()); ++i) {
    int u = adj[v][i];
    if (u != pai) {
      dfs_alt(u, h + 1, v);
      cont += contador[u];
      if (contador[u] > k) pode = false;
    }
  }
  if (pode && (2 * k - cont) <= k && esc == -1) esc = v;
  contador[v] = cont;
}
void dfs(int v, int pai, long long& saida, int h) {
  if (has_uni[v]) saida += h;
  for (int i = 0; i < ((int)adj[v].size()); ++i)
    if (adj[v][i] != pai) dfs(adj[v][i], v, saida, h + 1);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < 2 * k; ++i) {
    int aux;
    scanf("%d", &aux);
    has_uni[aux] = true;
  }
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  esc = -1;
  dfs_alt(1, 0, 0);
  long long saida = 0LL;
  dfs(esc, esc, saida, 0);
  cout << saida << endl;
}
