#include <bits/stdc++.h>
using namespace std;
vector<int> G[200004];
int n, k, x, y, i, A[200004];
long long s;
bool F[200004];
void DFS(int x, int f) {
  A[x] = F[x];
  int i, y;
  for (i = 0; i < G[x].size(); i++) {
    y = G[x][i];
    if (y == f) continue;
    DFS(y, x);
    A[x] += A[y];
  }
  s += min(A[x], k - A[x]);
}
int main() {
  scanf("%d%d", &n, &k);
  k <<= 1;
  for (i = 1; i <= k; i++) {
    scanf("%d", &x);
    F[x] = 1;
  }
  for (i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  DFS(1, 0);
  printf("%I64d", s);
}
