#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
struct sp {
  int q, id;
  sp *w;
  bool type;
  sp(int q, sp *w, int id, bool type) : q(q), w(w), id(id), type(type) {}
};
sp *a[N];
int s[N], isUni[N];
int f[N][2], sum[N];
int f2[N][2];
int calc(int q, int par) {
  int t;
  if (s[q] == -1) {
    sum[q] = isUni[q];
    for (sp *c = a[q]; c; c = c->w) {
      if (c->id != par) {
        sum[q] += calc(c->q, c->id);
      }
    }
    s[q] = par;
  }
  if (s[q] >= 0) {
    if (s[q] == par) {
      t = (f2[par][0] == q);
      f[par][t] = sum[q];
      return sum[q];
    }
    t = (f2[s[q]][0] == q);
    sum[q] += calc(f2[s[q]][t], s[q]);
    s[q] = -2;
  }
  if (par < 0) {
    return 0;
  } else {
    t = (f2[par][0] == q);
    f[par][t] = sum[q] - f[par][t ^ 1];
    return f[par][t];
  }
}
int sum_in_ch[N];
int calc_sum(int q, int par) {
  sum_in_ch[q] = isUni[q];
  for (sp *c = a[q]; c; c = c->w) {
    if (c->q != par) {
      sum_in_ch[q] += calc_sum(c->q, q);
    }
  }
  return sum_in_ch[q];
}
long long res = 0;
void calc_res(int q, int par) {
  if (par >= 0) {
    res += sum_in_ch[q];
  }
  for (sp *c = a[q]; c; c = c->w) {
    if (c->q != par) {
      calc_res(c->q, q);
    }
  }
}
int main() {
  int q, w, e, r, numP;
  scanf("%d%d", &q, &numP);
  for (w = 0; w < q; w++) {
    a[w] = 0;
    s[w] = -1;
    isUni[w] = 0;
  }
  for (w = 0; w < numP; w++) {
    scanf("%d%d", &e, &r);
    isUni[e - 1]++;
    isUni[r - 1]++;
  }
  for (w = 1; w < q; w++) {
    scanf("%d%d", &e, &r);
    e--;
    r--;
    a[e] = new sp(r, a[e], w, 0);
    a[r] = new sp(e, a[r], w, 1);
    f2[w][0] = e;
    f2[w][1] = r;
  }
  for (w = 0; w < q; w++) {
    calc(w, -2);
  }
  int bestN = -1, minSum = 1 << 20;
  for (w = 0; w < q; w++) {
    r = 0;
    for (sp *c = a[w]; c; c = c->w) {
      r = max(r, f[c->id][c->type]);
    }
    if (minSum > r) {
      minSum = r;
      bestN = w;
    }
  }
  calc_sum(bestN, -1);
  calc_res(bestN, -1);
  cout << res;
  return 0;
}
