#include <bits/stdc++.h>
using namespace std;
long long n, k, cnt[200005], x, y, ans;
vector<long long> v[200005];
void dfs(long long pos, long long pre) {
  long long len = v[pos].size();
  for (long long i = 0; i < len; i++) {
    long long xx = v[pos][i];
    if (xx != pre) {
      dfs(xx, pos);
      cnt[pos] += cnt[xx];
      ans += min(cnt[xx], 2 * k - cnt[xx]);
    }
  }
}
int main() {
  scanf("%lld%lld", &n, &k);
  for (long long i = 0; i < 2 * k; i++) {
    scanf("%lld", &x);
    cnt[x] = 1;
  }
  for (long long i = 0; i < n - 1; i++) {
    scanf("%lld%lld", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0);
  printf("%lld\n", ans);
}
