#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200002], uni;
map<int, int> mp;
int n, k;
bool vis[200002];
long long cnt[200002], dis[200002];
int dfs(int u, int parent) {
  if (vis[u]) {
    return cnt[u];
  }
  vis[u] = true;
  cnt[u] = mp[u];
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    if (parent != v) cnt[u] += dfs(adj[u][i], u);
  }
  return cnt[u];
}
int root_search(int u, int parent) {
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    if (cnt[v] > (2 * k - cnt[v]) && parent != v) {
      return root_search(v, u);
    }
  }
  return u;
}
void dfs1(int u, int parent, int level) {
  dis[u] = level;
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    if (v != parent) {
      dfs1(v, u, level + 1);
    }
  }
  return;
}
int main() {
  cin >> n >> k;
  int x;
  for (int i = 0; i < 2 * k; i++) {
    cin >> x;
    uni.push_back(x);
    mp[x] = 1;
  }
  int u, v;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  memset(vis, false, sizeof(vis));
  dfs(1, 0);
  int root = root_search(1, 0);
  dfs1(root, 0, 0);
  long long sum = 0;
  for (int i = 0; i < 2 * k; i++) {
    sum += dis[uni[i]];
  }
  cout << sum << endl;
  return 0;
}
