#include <bits/stdc++.h>
double eps = 1e-9;
using namespace std;
queue<int> q;
int n, m, par[200005], d[200005], cnt[200005];
int uni[200005];
long long sum;
vector<int> g[200005];
void dfs(int v, int p = 0) {
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to == p) continue;
    dfs(to, v);
    cnt[v] += cnt[to];
  }
  cnt[v] += uni[v];
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to == p) continue;
    sum = sum + (long long)((cnt[to] < m - cnt[to] ? cnt[to] : m - cnt[to]));
  }
}
int main() {
  cin >> n >> m;
  m *= 2;
  for (int i = 1; i <= m; i++) {
    int x;
    scanf("%d", &x);
    uni[x] = 1;
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1);
  cout << sum << endl;
}
