#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("Ofast")
using namespace std;
const int INF = 1e9 + 10;
const long long INFll = 2e18;
const int BASE1 = 179;
const int BASE2 = 653;
const long long MOD = 998244353;
const int MAXA = 2000001;
const int MAXN = 2e5 + 1;
const int MAXLOG = 22;
const long long COST = 1000 * 1000 * 1000;
const long double PI = 3.1415926535;
const long double EPS = 1e-15;
void calcdfs(int v, vector<vector<int> >& g, vector<int>& red,
             vector<int>& used, vector<int>& cntred, vector<int>& dist) {
  used[v] = 1;
  cntred[v] = red[v];
  for (auto u : g[v]) {
    if (!used[u]) {
      dist[u] = dist[v] + 1;
      calcdfs(u, g, red, used, cntred, dist);
      cntred[v] += cntred[u];
    }
  }
}
void dfs(int v, int p, vector<vector<int> >& g, vector<int>& red,
         vector<int>& cntred, int k, long long& res, long long del) {
  int v1 = -1, cnt = red[v];
  for (auto u : g[v]) {
    if (u == p) continue;
    if (cntred[u] - del > k)
      v1 = u;
    else
      cnt += cntred[u];
  }
  if (v1 == -1) return;
  del += cnt;
  k -= cnt;
  if (k <= 0) return;
  res += 2 * k;
  dfs(v1, v, g, red, cntred, k, res, del);
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<vector<int> > g(n);
  vector<int> red(n);
  for (int i = 0; i < (2 * k); i++) {
    int u;
    cin >> u;
    u--;
    red[u] = 1;
  }
  for (int i = 0; i < (n - 1); i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[y].emplace_back(x);
    g[x].emplace_back(y);
  }
  vector<int> cntred(n, 0), used(n, 0), dist(n, 0);
  calcdfs(0, g, red, used, cntred, dist);
  long long res = 0;
  dfs(0, -1, g, red, cntred, k, res, 0);
  res = -res;
  for (int i = 0; i < (n); i++) {
    if (red[i]) res += dist[i];
  }
  cout << res << "\n";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
