#include <bits/stdc++.h>
using namespace std;
int n, k;
bool uni[200000];
vector<int> adj[200000];
int dp[200000];
int par[200000];
void dfso(int no, int last) {
  par[no] = last;
  if (last == -1) par[no] = no;
  for (int i = 0; i < (int((adj[no]).size())); ++i) {
    int to = adj[no][i];
    if (to == last) continue;
    dfso(to, no);
    dp[no] += dp[to];
  }
  if (uni[no]) dp[no]++;
}
int chooseno = -1;
void dfsp(int no) {
  int maxi = 0;
  for (int i = 0; i < (int((adj[no]).size())); ++i) {
    if (adj[no][i] != par[no]) maxi = max(maxi, dp[adj[no][i]]);
  }
  int rem = 2 * k - dp[no];
  maxi = max(maxi, rem);
  if (maxi <= k) {
    chooseno = no;
  }
}
long long ans = 0;
void dfs3(int no, int last, int dep) {
  if (uni[no]) {
    ans += (long long)dep;
  }
  for (int i = 0; i < (int((adj[no]).size())); ++i) {
    int to = adj[no][i];
    if (to != last) dfs3(to, no, dep + 1);
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < (n); ++i) uni[i] = false;
  for (int i = 0; i < (2 * k); ++i) {
    int nxt;
    cin >> nxt;
    nxt--;
    uni[nxt] = true;
  }
  for (int i = 0; i < (n - 1); ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  par[0] = 0;
  dfso(0, -1);
  for (int i = 0; i < (n); ++i) {
    if (chooseno != -1) break;
    dfsp(i);
  }
  dfs3(chooseno, -1, 0);
  cout << ans << endl;
}
