#include <bits/stdc++.h>
using namespace std;
void PR(vector<int>& v) {
  for (auto& x : v) cout << x << ' ';
  cout << endl;
}
int N, K;
struct Node {
  bool isMarked = false;
  int nmarked;
  vector<int> children;
};
vector<Node> nodes;
vector<vector<int> > ed;
void dfs(int at, int par) {
  nodes[at].children.reserve(ed[at].size());
  for (auto& x : ed[at]) {
    if (x == par) continue;
    nodes[at].children.push_back(x);
    dfs(x, at);
    nodes[at].nmarked += nodes[x].nmarked;
  }
  nodes[at].nmarked += nodes[at].isMarked;
}
long long res = 0;
void dfs2(int at, int wantedExcess) {
  Node& n = nodes[at];
  assert(n.nmarked >= wantedExcess);
  vector<pair<int, int> > req;
  req.reserve(n.children.size() + 1);
  if (n.isMarked) req.emplace_back(1, -1);
  for (int i = 0; i < ((int)(n.children).size()); ++i) {
    int x = n.children[i];
    req.emplace_back(nodes[x].nmarked, i);
  }
  if (req.empty()) return;
  sort(req.begin(), req.end());
  reverse(req.begin(), req.end());
  res += wantedExcess;
  int rem = req[0].first - wantedExcess;
  if (rem * 2 > (n.nmarked - wantedExcess)) {
    assert(req[0].second != -1);
    int others = n.nmarked - req[0].first + wantedExcess;
    assert(others < req[0].first);
    for (int i = 0; i < ((int)(n.children).size()); ++i) {
      int x = n.children[i];
      if (i == req[0].second) {
        dfs2(x, others);
      } else {
        dfs2(x, nodes[x].nmarked);
      }
    }
  } else {
    for (auto& x : n.children) {
      dfs2(x, nodes[x].nmarked);
    }
  }
}
int main() {
  cin.sync_with_stdio(false);
  cin.exceptions(cin.failbit);
  cin >> N >> K;
  ed.resize(N);
  nodes.resize(N);
  for (int i = 0; i < (2 * K); ++i) {
    int v;
    cin >> v;
    --v;
    nodes[v].isMarked = 1;
  }
  for (int i = 0; i < (N - 1); ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    ed[a].push_back(b);
    ed[b].push_back(a);
  }
  dfs(0, -1);
  dfs2(0, 0);
  cout << res << endl;
  exit(0);
}
