#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int n, k;
vector<int> us;
vector<set<int>> g;
int main(int argc, char **argv) {
  ;
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  vector<int> us(n, 0);
  for (int i = 0; i < (int)(2 * k); i++) {
    int u;
    cin >> u;
    us[u - 1] = 1;
  }
  g = vector<set<int>>(n);
  for (int i = 0; i < (int)(n - 1); i++) {
    int t1, t2;
    cin >> t1 >> t2;
    t1--;
    t2--;
    g[t1].insert(t2);
    g[t2].insert(t1);
    ;
  };
  priority_queue<pair<int, int>> leaves;
  vector<int> deg(n, 0);
  for (int i = 0; i < (int)(n); i++) {
    deg[i] = g[i].size();
    if (deg[i] == 1) {
      leaves.push({-us[i], i});
    }
  };
  map<pair<int, int>, int> values;
  while (!leaves.empty()) {
    int val, node;
    tie(val, node) = leaves.top();
    val = -val;
    leaves.pop();
    for (int next : g[node]) {
      ;
      values[{min(node, next), max(node, next)}] = us[node];
      us[next] += us[node];
      g[next].erase(node);
      ;
      if (g[next].size() == 1) {
        leaves.push({-us[next], next});
      }
    }
  }
  long long cables = 0;
  for (auto p : values) {
    ;
    cables += p.second;
  }
  cout << cables << endl;
  return 0;
}
