#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 1233;
int n, m;
vector<int> g[N];
long long b[N], ans;
void dfs(int v, int pr = -1) {
  for (int u : g[v])
    if (pr != u) dfs(u, v), b[v] += b[u];
  ans += min(b[v], 2 * m - b[v]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m * 2; i++) {
    int x;
    cin >> x;
    b[x] = 1;
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y), g[y].push_back(x);
  }
  dfs(1);
  cout << ans;
}
