#include <bits/stdc++.h>
using namespace std;
long long int n, k;
set<int> s;
const int S = 2e5 + 5;
vector<int> adj[S];
vector<long long int> child(S, 0);
long long int to = -1, from;
set<int> sec;
void dfs(int idx, int p) {
  child[idx] = s.count(idx);
  for (auto x : adj[idx]) {
    if (x == p) continue;
    dfs(x, idx);
    if (to == -1)
      if (child[x] >= k) {
        to = x;
        from = idx;
      }
    child[idx] += child[x];
  }
  if (to == -1)
    if (child[idx] >= k) {
      to = idx;
      from = p;
    }
}
void dfs2(int idx, int p) {
  if (s.count(idx)) sec.insert(idx);
  for (auto x : adj[idx]) {
    if (x == p) continue;
    dfs2(x, idx);
  }
}
void dfsd(int idx, int p, int lv, vector<long long int>& a) {
  a[idx] = lv;
  for (auto x : adj[idx]) {
    if (x == p) continue;
    dfsd(x, idx, lv + 1, a);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  int x, y;
  for (int i = 0; i < 2 * k; i++) {
    cin >> x;
    s.insert(x);
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, -1);
  if (to == -1) return cout << "MWAHAHAH" << '\n', 0;
  dfs2(to, from);
  vector<long long int> dist(n + 5, 0), disf(n + 5, 0);
  dfsd(to, -1, 0, dist);
  dfsd(from, -1, 0, disf);
  long long int ans = 0;
  for (auto x : s) {
    if (sec.count(x))
      ans += dist[x];
    else
      ans += dist[x];
  }
  cout << ans << '\n';
}
