#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod(ll A, ll M) { return (A % M + M) % M; }
const ll INF = 1LL << 60;
template <class T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
ll divceil(ll A, ll B) { return (A + (B - 1)) / B; }
ll myctoi(char C) { return C - '0'; }
char myitoc(ll N) { return '0' + N; }
ll N, U, V;
vector<vector<ll>> G;
vector<bool> visited;
vector<ll> TtoA;
void dfs1(ll v, ll l) {
  if (visited.at(v)) return;
  visited.at(v) = true;
  TtoA.at(v) = l;
  for (auto nv : G.at(v)) {
    dfs1(nv, l + 1);
  }
}
ll L = -1;
ll lp = -1;
void dfs2(ll v, ll l) {
  if (TtoA.at(v) * 2 < TtoA.at(U)) return;
  if (visited.at(v)) return;
  visited.at(v) = true;
  if (chmax(L, l)) lp = v;
  for (auto nv : G.at(v)) {
    dfs2(nv, l + 1);
  }
}
int main() {
  cin >> N >> U >> V;
  U--, V--;
  G.resize(N);
  for (ll i = 0; i < N - 1; i++) {
    ll A, B;
    cin >> A >> B;
    A--, B--;
    G.at(A).push_back(B);
    G.at(B).push_back(A);
  }
  visited = vector<bool>(N, false);
  TtoA = vector<ll>(N, 0);
  dfs1(V, 0);
  visited = vector<bool>(N, false);
  dfs2(U, 0);
  ll ans = TtoA.at(lp) - 1;
  cout << ans << endl;
}
