#include <bits/stdc++.h>
using namespace std;
class node {
 public:
  int num;
  bool is_root = false;
  node* pred;
  vector<node*> sons;
  int marked = 0;
  int num_sons_marked;
  long long sum_of_paths;
  void process() {
    if (is_root) {
      if (sons.size() == 0) {
        num_sons_marked = marked;
        sum_of_paths = 0;
        return;
      } else {
        num_sons_marked = marked;
        sum_of_paths = 0;
        for (int i = 0; i < sons.size(); ++i) {
          sons[i]->pred = this;
          sons[i]->process();
          num_sons_marked += sons[i]->num_sons_marked;
          sum_of_paths += sons[i]->sum_of_paths + sons[i]->num_sons_marked;
        }
        return;
      }
    } else {
      if (sons.size() == 1) {
        num_sons_marked = marked;
        sum_of_paths = 0;
        return;
      } else {
        num_sons_marked = marked;
        sum_of_paths = 0;
        for (int i = 0; i < sons.size(); ++i) {
          if (sons[i]->num != pred->num) {
            sons[i]->pred = this;
            sons[i]->process();
            num_sons_marked += sons[i]->num_sons_marked;
            sum_of_paths += sons[i]->sum_of_paths + sons[i]->num_sons_marked;
          }
        }
        return;
      }
    }
  }
  long long calc() {
    bool is_normal = true;
    int which_bad;
    for (int i = 0; i < sons.size(); ++i) {
      if (sons[i]->num != pred->num || is_root) {
        if (sons[i]->num_sons_marked * 2 > num_sons_marked) {
          is_normal = false;
          which_bad = i;
        }
      }
    }
    if (is_normal) {
      return sum_of_paths;
    } else {
      int other = num_sons_marked - sons[which_bad]->num_sons_marked;
      long long part_ans = sum_of_paths - sons[which_bad]->sum_of_paths -
                           sons[which_bad]->num_sons_marked + other;
      sons[which_bad]->marked += other;
      sons[which_bad]->num_sons_marked += other;
      return sons[which_bad]->calc() + part_ans;
    }
  }
};
void solve() {
  int n;
  int k;
  cin >> n >> k;
  vector<node> tree(n);
  int cur_f, cur_s;
  vector<int> marked(2 * k);
  for (int i = 0; i < 2 * k; ++i) {
    cin >> marked[i];
    tree[marked[i] - 1].marked = 1;
  }
  for (int i = 0; i < n; ++i) {
    tree[i].num = i;
  }
  for (int i = 0; i < n - 1; ++i) {
    cin >> cur_f >> cur_s;
    tree[cur_f - 1].sons.push_back(&tree[cur_s - 1]);
    tree[cur_s - 1].sons.push_back(&tree[cur_f - 1]);
  }
  tree[0].is_root = true;
  tree[0].pred = &tree[0];
  tree[0].process();
  cout << tree[0].calc() << endl;
  return;
}
int main() {
  solve();
  return 0;
}
