#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long powmod(long long a, long long b, long long MOD) {
  long long ans = 1;
  while (b) {
    if (b % 2) ans = ans * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return ans;
}
const int N = 1e5 + 11;
int siz[N], fa[N], son[N], a[N], cnt, to[N], t[N], de[N];
int T[N << 2];
int laz[N << 2];
vector<int> v[N];
int n, m, p, r, x[N];
void dfs1(int now, int pre, int d) {
  siz[now] = 1;
  fa[now] = pre;
  de[now] = d;
  int cnt = -1;
  for (auto k : v[now]) {
    if (k == pre) continue;
    dfs1(k, now, d + 1);
    siz[now] += siz[k];
    if (siz[k] > cnt) {
      cnt = siz[k];
      son[now] = k;
    }
  }
}
void dfs2(int now, int pre) {
  to[now] = pre;
  a[now] = ++cnt;
  t[cnt] = x[now];
  if (!son[now]) return;
  dfs2(son[now], pre);
  for (auto k : v[now]) {
    if (k == fa[now] || k == son[now]) continue;
    dfs2(k, k);
  }
}
int find_lca(int l, int r) {
  int res = 0, x = l, y = r;
  while (to[l] != to[r]) {
    if (de[to[l]] < de[to[r]]) swap(l, r);
    l = fa[to[l]];
  }
  if (de[l] > de[r]) swap(l, r);
  return de[x] + de[y] - 2 * de[l];
}
int xa, xb;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> xa >> xb;
  for (int i = 1; i < n; i++) {
    int s, t;
    cin >> s >> t;
    v[s].push_back(t);
    v[t].push_back(s);
  }
  dfs1(1, 0, 0);
  dfs2(1, 1);
  int sta = 1, ans = 0;
  while (xa != xb) {
    if (sta & 1) {
      if (xa == xb) break;
      int ma = -1, ne;
      for (auto k : v[xa]) {
        int cnt = find_lca(xb, k);
        if (cnt > ma) {
          ma = cnt;
          ne = k;
        }
      }
      xa = ne;
    } else {
      if (xa == xb) break;
      ans++;
      int ma = 1e9, ne;
      for (auto k : v[xb]) {
        int cnt = find_lca(xa, k);
        if (cnt < ma) {
          ma = cnt;
          ne = k;
        }
      }
      xb = ne;
    }
    sta ^= 1;
  }
  cout << ans << '\n';
  return 0;
}
