#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long int INF = 1e18;
const int N = 2e5 + 1;
vector<int> adj[N];
bool val[N];
int r1, r2;
long long int best = INF;
long long int res = 0;
int n, k;
int dfs1(int s, int p) {
  int cnt = val[s];
  for (int c : adj[s]) {
    if (c != p) {
      cnt += dfs1(c, s);
    }
  }
  if (cnt >= k && cnt < best) {
    best = cnt;
    r2 = s;
  }
  return cnt;
}
void dfs2(int s, int p, int d) {
  if (val[s]) res += (1LL * d);
  for (int c : adj[s]) {
    if (c == p) continue;
    dfs2(c, s, d + 1);
  }
}
void MUI() {
  cin >> n >> k;
  for (int i = (0); i < (2 * k); ++i) {
    int v;
    cin >> v;
    val[v] = 1;
  }
  for (int i = (0); i < (n - 1); ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    if (adj[u].size() == 1) r1 = u;
    if (adj[v].size() == 1) r1 = v;
  }
  dfs1(r1, -1);
  dfs2(r2, -1, 0);
  cout << res << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  while (T--) {
    MUI();
  }
  return 0;
}
