#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > adj;
vector<long long> U;
vector<long long> tot, sz;
int K;
void dfs1(int u, int p = -1, int LVL = 0) {
  tot[u] = 0;
  sz[u] = U[u];
  for (int v : adj[u]) {
    if (p == v) continue;
    dfs1(v, u, LVL + 1);
    tot[u] += tot[v] + sz[v];
    sz[u] += sz[v];
  }
  int REM = 2 * K - sz[u];
  if (REM < sz[u]) {
    K -= (sz[u] - REM) / 2;
    sz[u] = REM;
  }
}
int main() {
  int N;
  cin >> N >> K;
  adj = vector<vector<long long> >(N);
  U = vector<long long>(N);
  tot = vector<long long>(N, 0);
  sz = vector<long long>(N, 0);
  for (int i = 0; i < 2 * K; ++i) {
    int u;
    cin >> u;
    u--;
    U[u] = 1;
  }
  for (int i = 0; i < N - 1; ++i) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs1(0);
  cout << tot[0] << endl;
}
