#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n, nodes, ans = 0;
long long mark[N], subtree[N];
vector<long long> g[N];
void dfs(long long k, long long par) {
  subtree[k] = mark[k];
  for (auto it : g[k]) {
    if (it == par) continue;
    dfs(it, k);
    subtree[k] += subtree[it];
  }
  ans += min(subtree[k], 2 * nodes - subtree[k]);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> nodes;
  for (long long i = 1; i <= 2 * nodes; i++) {
    long long u;
    cin >> u;
    mark[u] = 1;
  }
  for (long long i = 1; i <= n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0);
  cout << ans;
  return 0;
}
