#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[100005];
long long a[100005], lvl[100005], p[100005][20];
long long ans = 0, x, y;
void dfs(long long u, long long par) {
  p[u][0] = par;
  lvl[u] = lvl[par] + 1;
  for (auto v : adj[u]) {
    if (v == par) continue;
    dfs(v, u);
  }
}
long long lca(long long u, long long v) {
  long long i, lg;
  if (lvl[u] < lvl[v]) swap(u, v);
  for (lg = 0; (1 << lg) <= lvl[u]; lg++)
    ;
  lg--;
  for (i = lg; i >= 0; i--) {
    if ((lvl[u] - (1 << i)) >= lvl[v]) u = p[u][i];
  }
  if (u == v) return u;
  for (i = lg; i >= 0; i--) {
    if (p[u][i] != -1 && p[u][i] != p[v][i]) {
      u = p[u][i];
      v = p[v][i];
    }
  }
  return p[u][0];
}
long long getAncestor(long long u, long long dis) {
  dis = lvl[u] - dis;
  long long i, lg;
  for (lg = 0; (1 << lg) <= lvl[u]; lg++)
    ;
  lg--;
  for (i = lg; i >= 0; i--) {
    if (lvl[u] - (1 << i) >= dis) u = p[u][i];
  }
  return u;
}
long long dis(long long u, long long v) {
  if (lvl[u] < lvl[v]) swap(u, v);
  long long w = lca(u, v);
  return lvl[u] + lvl[v] - 2 * lvl[w];
}
void DFS(long long v, long long par) {
  vector<pair<long long, long long> > t;
  for (auto p : adj[v]) {
    if (p != par) {
      t.push_back({lvl[p], p});
    }
  }
  sort(t.begin(), t.end(), greater<pair<long long, long long> >());
  if (t.size() == 1) {
    ans++;
    DFS(t[0].second, v);
  } else if (!t.empty()) {
    if (dis(x, v) < dis(y, v)) {
      ans++;
      DFS(t[0].second, v);
    } else {
      for (auto p : t) {
        if (lca(x, p.second) == p.second) {
          ans++;
          DFS(p.second, v);
          break;
        }
      }
    }
  }
}
int main() {
  long long i, u, v, j, n;
  cin >> n >> x >> y;
  for (i = 1; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (i = 0; i < 20; i++) {
    for (j = 1; j <= n; j++) {
      p[j][i] = -1;
    }
  }
  lvl[0] = -1;
  dfs(y, 0);
  for (i = 1; i < 20; i++) {
    for (j = 1; j <= n; j++) {
      if (p[j][i - 1] != -1) p[j][i] = p[p[j][i - 1]][i - 1];
    }
  }
  DFS(y, 0);
  cout << max(ans - 1, 0LL);
}
