#include <bits/stdc++.h>
using namespace std;
class Solution {
  vector<vector<int> > tr;
  vector<int> vi, cnt;
  int n, m;
  long long ret;

 public:
  void init() {
    cin >> n >> m;
    tr = vector<vector<int> >(n + 1);
    vi = cnt = vector<int>(n + 1, 0);
    for (int i = 0; i < 2 * m; i++) {
      int x;
      cin >> x;
      vi[x] = 1;
    }
    for (int i = 1; i < n; i++) {
      int x, y;
      cin >> x >> y;
      tr[x].push_back(y);
      tr[y].push_back(x);
    }
  }
  void dfs(int st, int f) {
    cnt[st] = vi[st];
    for (int i = 0; i < (int)tr[st].size(); i++) {
      int to = tr[st][i];
      if (to == f) continue;
      dfs(to, st);
      ret += min(cnt[to], 2 * m - cnt[to]);
      cnt[st] += cnt[to];
    }
  }
  void solve() {
    ret = 0;
    dfs(1, -1);
    cout << ret << endl;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  Solution* sol = new Solution();
  sol->init();
  sol->solve();
  return 0;
}
