#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  set<int> cities;
  map<int, int> nodes;
  for (long long int k = (0); k < (long long int)(2 * K); ++k) {
    int x;
    cin >> x;
    cities.insert(x - 1);
    nodes[x - 1] = 1;
  }
  vector<bool> leafs(N, true);
  map<int, set<int> > edges;
  for (long long int n = (0); n < (long long int)(N - 1); ++n) {
    int x, y;
    cin >> x >> y;
    edges[x - 1].insert(y - 1);
    edges[y - 1].insert(x - 1);
    if (edges[x - 1].size() > 1) leafs[x - 1] = false;
    if (edges[y - 1].size() > 1) leafs[y - 1] = false;
  }
  map<pair<int, int>, int> flow;
  priority_queue<pair<int, int> > q;
  for (long long int n = (0); n < (long long int)(N); ++n) {
    if (leafs[n]) q.push({-nodes[n], n});
  }
  int end;
  while (!q.empty()) {
    int x = q.top().second;
    q.pop();
    int y = *edges[x].begin();
    flow[{y, x}] = nodes[x];
    nodes[y] += nodes[x];
    if (nodes[y] == 2 * K) {
      end = y;
      break;
    }
    edges[x].erase(y);
    edges[y].erase(x);
    if (edges[y].size() == 1) {
      q.push({-nodes[y], y});
    }
  }
  long long int sum = 0;
  for (auto x : flow) {
    sum += x.second;
  }
  cout << sum << endl;
  return 0;
}
