#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
vector<long long> adj[N];
long long b[N], ans = 0, n, k;
void dfs(int a, int p = -1) {
  for (auto i : adj[a]) {
    if (i == p) continue;
    dfs(i, a);
    b[a] += b[i];
  }
  ans += min(b[a], k - b[a]);
}
int main() {
  int x, u, v;
  cin >> n >> k;
  k *= 2;
  for (int i = 0; i < k; i++) {
    cin >> x;
    b[x]++;
  }
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1);
  cout << ans << endl;
}
