#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000000 + 10;
int num[maxn], vis[maxn], used[maxn], n, k;
long long ans = 0;
vector<int> E[maxn];
void dfs(int root, int father) {
  num[root] = used[root];
  for (int i = 0; i < E[root].size(); i++) {
    int son = E[root][i];
    if (son == father) continue;
    dfs(son, root);
    num[root] += num[son];
  }
  ans += min(num[root], 2 * k - num[root]);
}
int main() {
  while (~scanf("%d %d", &n, &k)) {
    memset(vis, 0, sizeof(vis));
    memset(used, 0, sizeof(used));
    memset(num, 0, sizeof(num));
    for (int i = 1; i <= n; i++) E[i].clear();
    for (int i = 0; i < 2 * k; i++) {
      int x;
      scanf("%d", &x);
      used[x] = 1;
    }
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      scanf("%d %d", &a, &b);
      E[a].push_back(b);
      E[b].push_back(a);
    }
    ans = 0;
    dfs(1, 0);
    printf("%I64d\n", ans);
  }
}
