#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
void dfs(int u, int p, int depth, vector<lli> &dist,
         const vector<vector<int>> &e) {
  dist[u] = depth;
  for (auto s : e[u]) {
    if (s == p) continue;
    dfs(s, u, depth + 1, dist, e);
  }
}
vector<lli> dist(vector<vector<int>> &e, int u) {
  int N = e.size();
  vector<lli> v(N, -1);
  dfs(u, -1, 0, v, e);
  return v;
}
void solve(long long N, long long u, long long v, std::vector<long long> A,
           std::vector<long long> B) {
  vector<vector<int>> e(N);
  u--, v--;
  for (lli i = 0; i < (N - 1); i++) A[i]--, B[i]--;
  for (lli i = 0; i < (N - 1); i++)
    e[A[i]].push_back(B[i]), e[B[i]].push_back(A[i]);
  auto u_dist = dist(e, u);
  auto v_dist = dist(e, v);
  vector<bool> ok(N);
  for (lli i = 0; i < (N); i++) ok[i] = u_dist[i] < v_dist[i];
  vector<vector<int>> e_sub(N);
  for (lli i = 0; i < (N - 1); i++)
    if (ok[A[i]] && ok[B[i]])
      e_sub[A[i]].push_back(B[i]), e_sub[B[i]].push_back(A[i]);
  auto u_sub_dist = dist(e_sub, u);
  lli ans = 0;
  lli dst = 0;
  lli cnt = 0;
  for (lli i = 0; i < (N); i++) {
    if (u_sub_dist[i] >= 0) {
      cnt++;
    }
  }
  cerr << cnt << endl;
  if (cnt == 1) {
    cout << (e[u][0] == v ? 0 : 1) << endl;
    return;
  }
  for (lli i = 0; i < (N); i++) {
    if (u_sub_dist[i] >= 0) {
      chmax(ans, -(1 & (u_sub_dist[i] + v_dist[i])) + v_dist[i]);
    }
  }
  cout << ans << endl;
}
signed main() {
  long long N;
  scanf("%lld", &N);
  long long u;
  scanf("%lld", &u);
  long long v;
  scanf("%lld", &v);
  std::vector<long long> A(N - 1);
  std::vector<long long> B(N - 1);
  for (int i = 0; i < N - 1; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, u, v, std::move(A), std::move(B));
  return 0;
}
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}
