#include <bits/stdc++.h>
using namespace std;
list<int> G[234567];
int n, k, s[234567];
long long ans;
void dfs(int pos, int parent) {
  list<int>::iterator it = G[pos].begin(), ed = G[pos].end();
  for (; it != ed; ++it) {
    int to = *it;
    if (parent == to) continue;
    dfs(to, pos);
    s[pos] += s[to];
  }
  ans += min(s[pos], k - s[pos]);
}
int main() {
  scanf(" %d %d", &n, &k);
  k *= 2;
  for (int i = 0; i < k; ++i) {
    static int t;
    scanf(" %d", &t);
    ++s[t];
  }
  for (int i = 1; i < n; ++i) {
    static int a, b;
    scanf(" %d %d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(1, 0);
  printf("%I64d\n", ans);
  return 0;
}
