#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
const long long maxn = 2e5 + 10, LG = 22, mod = 1e9 + 7, inf = 1e18;
long long n, k;
long long siz[maxn];
bool uni[maxn];
vector<long long> g[maxn];
void dfsz(long long v = 1, long long p = 1) {
  siz[v] += uni[v];
  for (auto u : g[v])
    if (u != p) {
      dfsz(u, v);
      siz[v] += siz[u];
    }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long v, u;
  cin >> n >> k;
  k *= 2;
  for (int i = 0; i < k; i++) cin >> v, uni[v] = 1;
  for (int i = 1; i < n; i++) {
    cin >> v >> u;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  dfsz();
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += min(siz[i], k - siz[i]);
  cout << ans << endl;
  return 0;
}
