#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, u, v;
  cin >> N >> u >> v;
  u--; v--;
  vector<vector<int>> G(N);
  F0R(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> vd(N);
  auto search = [&](auto search, int v, int d = 0, int p = -1)->void {
    vd[v] = d;
    for (auto c : G[v]) {
      if (c == p)continue;
      search(search, c, d + 1, v);
    }
  };
  search(search, v);
  //Print(vd);

  int best = -1, result;
  auto run = [&](auto run, int v, int d = 0, int p = -1)->void {
    bool delayedReturn = false;
    if (vd[v] < d) {
      return;
    }
    else if (vd[v] == d) {
      delayedReturn = true;
    }
    if (d > best) {
      best = d;
      result = vd[v];
      if ((vd[v] - d) & 1) result--;
    }
    if (delayedReturn) return;
    //debug(v);
    for (auto c : G[v]) {
      if (c == p) continue;
      run(run, c, d + 1, v);
    }
  };
  run(run, u);
  cout << result;
}
#endif
