#include <bits/stdc++.h>
using namespace std;
int N, u, v;
vector<vector<int>> G;
int alphabeta(bool t, int n, int u, int v, int alpha, int beta) {
  if (n >= N || u == v) return n;
  if (t) {
    for (int w : G[u]) {
      alpha = max(alpha, alphabeta(!t, n, w, v, alpha, beta));
      if (beta <= alpha) return alpha;
    }
    return alpha;
  } else {
    for (int w : G[v]) {
      beta = min(beta, alphabeta(!t, n + 1, u, w, alpha, beta));
      if (beta <= alpha) return beta;
    }
    return beta;
  }
}
int main() {
  cin >> N >> u >> v;
  --u, --v;
  G.resize(N);
  for (int i = 0; i < (int)N - 1; ++i) {
    int A, B;
    cin >> A >> B;
    --A, --B;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  cout << alphabeta(true, 0, u, v, 0, N) << endl;
  return 0;
}
