#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
vector<ll> G[110000];
ll d[110000], td[110000];
signed main() {
  ll n, u, v, ans = 0;
  cin >> n >> u >> v;
  u--;
  v--;
  ll a, b;
  priority_queue<P, vector<P>, greater<P>> que;
  for (int i = 0; i < n - 1; i++) {
    scanf("%lld %lld", &a, &b);
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
    d[i] = 1000000000;
    td[i] = 1000000000;
  }
  d[n - 1] = 1000000000;
  td[n - 1] = 1000000000;
  que.push(P(v, 0));
  while (!que.empty()) {
    P tmp = que.top();
    que.pop();
    ll v = tmp.first, dis = tmp.second;
    if (d[v] <= dis) {
      continue;
    }
    d[v] = dis++;
    for (auto nx : G[v]) {
      que.push(P(nx, dis));
    }
  }
  priority_queue<P, vector<P>, greater<P>> quu;
  quu.push(P(u, 0));
  while (!quu.empty()) {
    P tmp = quu.top();
    quu.pop();
    ll v = tmp.first, dis = tmp.second;
    if (td[v] <= dis) {
      continue;
    }
    if (d[v] <= dis && d[v] % 2 != dis % 2) continue;
    td[v] = dis;
    if (d[v] <= dis) continue;
    dis++;
    for (auto nx : G[v]) {
      quu.push(P(nx, dis));
    }
  }
  ll val;
  for (int i = 0; i < n; i++) {
    val = td[i];
    if (td[i] == 1000000000) continue;
    if (ans < val) ans = val;
  }
  if (ans < 0) ans = 0;
  cout << ans << endl;
}
