#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 3;
vector<int> adj[M];
bool uni[M];
int n, k;
int cnt[M], goodvertex = -1;
long long ans;
void dfs(int v, int dad = -1) {
  if (uni[v]) cnt[v]++;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (u == dad) continue;
    dfs(u, v);
    cnt[v] += cnt[u];
  }
  if (cnt[v] >= k && goodvertex < 0) goodvertex = v;
}
void dfs2(int v, int d = 0, int dad = -1) {
  if (uni[v]) ans += d;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (u == dad) continue;
    dfs2(u, d + 1, v);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 0; i < 2 * k; i++) {
    int x;
    cin >> x;
    uni[--x] = 1;
  }
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(0);
  dfs2(goodvertex);
  cout << ans << endl;
}
