#include <bits/stdc++.h>
using namespace std;
int n, m, kid[200200], best;
vector<int> g[200200];
bool uni[200200];
long long ans;
int dfs(int i, int p) {
  kid[i] = uni[i];
  int mac = 0;
  for (auto j : g[i]) {
    if (j == p) {
      continue;
    }
    int tmp = dfs(j, i);
    mac = max(mac, tmp);
    kid[i] += tmp;
  }
  mac = max(mac, m + m - kid[i]);
  if (mac <= m) {
    best = i;
  }
  return kid[i];
}
void sum(int i, int p, int d) {
  if (uni[i]) {
    ans += d;
  }
  for (auto j : g[i]) {
    if (j == p) {
      continue;
    }
    sum(j, i, d + 1);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0, j; i < m + m; ++i) {
    cin >> j;
    uni[j] = 1;
  }
  for (int k = 1, i, j; k < n; ++k) {
    cin >> i >> j;
    g[i].emplace_back(j);
    g[j].emplace_back(i);
  }
  dfs(1, 0);
  sum(best, 0, 0);
  cout << ans << "\n";
}
