#include <bits/stdc++.h>
using namespace std;
inline void out(int a) { printf("%d ", a); }
inline void out(long long a) { printf("%I64d ", a); }
inline void out(double a) { printf("%.12lf ", a); }
inline void get(int &a) { scanf("%d", &a); }
inline void get(long long &a) { scanf("%I64d", &a); }
inline void get(double &a) { scanf("%lf", &a); }
template <typename T>
inline void get(vector<T> &v, int n) {
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    get(v[i]);
  }
}
long long ans;
int k;
long long dfs(int current, int previos, vector<long long> &v,
              vector<vector<int>> &g) {
  for (auto i : g[current]) {
    if (i == previos) {
      continue;
    }
    v[current] += dfs(i, current, v, g);
  }
  ans += min(v[current], k * 2 - v[current]);
  return v[current];
}
int main() {
  int n;
  get(n);
  get(k);
  vector<long long> v(n + 1, 0);
  vector<vector<int>> g(n + 1);
  for (int i = 0; i < k * 2; ++i) {
    int a;
    get(a);
    v[a]++;
  }
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    get(a);
    get(b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, 0, v, g);
  out(ans);
  return 0;
}
