#include <bits/stdc++.h>
const int N = 200100;
using namespace std;
vector<long long int> v[N];
long long int n, down[N], up[N], k, s[N], a[N];
long long int ans;
void f(long long int x, long long int p) {
  s[x] = a[x];
  for (int i = 0; i < v[x].size(); i++) {
    long long int y = v[x][i];
    if (y == p) continue;
    f(y, x);
    s[x] += s[y];
    down[x] += down[y] + s[y];
  }
}
void dfs(long long int x, long long int p) {
  long long int mx = k + k - s[x];
  for (int i = 0; i < v[x].size(); i++) {
    long long int y = v[x][i];
    if (y == p) continue;
    up[y] = up[x] + down[x] - down[y] - s[y] + k + k - s[y];
    dfs(y, x);
    mx = max(mx, s[y]);
  }
  if (mx <= k) ans = max(ans, up[x] + down[x]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= k + k; i++) {
    long long int x;
    cin >> x;
    a[x] = 1;
  }
  for (int i = 1; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  f(1, -1);
  dfs(1, -1);
  cout << ans << endl;
}
