#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> v[200010];
int countt[200010];
bool need[200010];
long long ans, dis[200010];
void dfs(int dad, int nod) {
  countt[nod] = need[nod];
  for (int i = 0; i < v[nod].size(); ++i) {
    int temp = v[nod][i];
    if (temp != dad) {
      dfs(nod, temp);
      countt[nod] += countt[temp];
      dis[nod] += dis[temp] + countt[temp];
    }
  }
}
void dfs2(int dad, int nod, int ct, long long diss) {
  int mx = ct;
  for (int i = 0; i < v[nod].size(); ++i) {
    int temp = v[nod][i];
    if (temp != dad) {
      mx = max(mx, countt[temp]);
      dfs2(nod, temp, ct + countt[nod] - countt[temp],
           (diss + ct) + (dis[nod] - dis[temp] - countt[temp]) + countt[nod] -
               countt[temp]);
    }
  }
  if (mx <= k) {
    ans = max(ans, diss + dis[nod]);
  }
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= 2 * k; ++i) {
    int x;
    cin >> x;
    need[x] = 1;
  }
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(0, 1);
  dfs2(0, 1, 0, 0);
  cout << ans;
  return 0;
}
