#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[n - 1], b[n - 1];
  fill(d, d + n, 1000000000);
  fill(td, td + n, -1);
  priority_queue<P, vector<P>, greater<P>> que;
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  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));
    }
  }
  que.push(P(u, 0));
  while (!que.empty()) {
    P tmp = que.top();
    que.pop();
    ll v = tmp.first, dis = tmp.second;
    if (td[v] >= dis) {
      continue;
    }
    td[v] = dis;
    if (d[v] <= dis) continue;
    dis++;
    for (auto nx : G[v]) {
      que.push(P(nx, dis));
    }
  }
  ll val;
  for (int i = 0; i < n; i++) {
    val = td[i];
    if (td[i] % 2 != d[i] % 2) {
      val--;
    }
    ans = max(ans, val);
  }
  ans = max(ans, 0ll);
  cout << ans << endl;
}
