#include <bits/stdc++.h>
using namespace std;
int nd[200010];
vector<int> cn[200010];
bool vis[200010];
long long anw;
int k;
int ts(int x) {
  vis[x] = true;
  int r = nd[x];
  for (int i = 0; i < cn[x].size(); i++) {
    int v = cn[x][i];
    if (vis[v]) continue;
    r += ts(v);
  }
  anw += min(r, k - r);
  return r;
}
int main() {
  int n;
  scanf("%d%d", &n, &k);
  k *= 2;
  for (int i = 0; i < k; i++) {
    int t;
    scanf("%d", &t);
    t--;
    nd[t]++;
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    cn[x].push_back(y);
    cn[y].push_back(x);
  }
  ts(0);
  cout << anw << endl;
}
