#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
using pv = vector<pair<T, U>>;
template <typename T>
using pque = priority_queue<T>;
template <typename T>
using lpque = priority_queue<T, vector<T>, greater<T>>;
using ll = long long;
using intpair = pair<int, int>;
using llpair = pair<ll, ll>;
using ilpair = pair<int, ll>;
using lipair = pair<ll, int>;
using intvec = vector<int>;
using llvec = vector<ll>;
using intq = queue<int>;
using llq = queue<ll>;
using intmat = vector<intvec>;
using llmat = vector<llvec>;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline void init(T& v) {
  for (auto& a : v) cin >> a;
}
template <class T, class U>
inline void init(vector<pair<T, U>>& v) {
  for (auto& a : v) cin >> a.first >> a.second;
}
template <class T, class N>
inline void init(T& v, N n) {
  v.resize(n);
  for (auto& a : v) cin >> a;
}
template <class T, class U, class N>
inline void init(vector<pair<T, U>>& v, N n) {
  v.resize(n);
  for (auto& a : v) cin >> a.first >> a.second;
}
inline void out() { cout << endl; }
template <class T, class... U>
inline void out(T a, U... alist) {
  cout << a << " ";
  out(forward<U>(alist)...);
}
template <class N>
void resiz(N n) {}
template <class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
  hd.resize(n);
  resiz(n, forward<U>(tl)...);
}
bool isout(int h, int w, int H, int W) {
  return (h < 0 || h >= H || w < 0 || w >= W);
}
ll binpow(ll a, ll ex, ll p) {
  ll result = 1;
  while (ex > 0) {
    if (ex & 1) result = result * a % p;
    ex >>= 1;
    a = a * a % p;
  }
  return result;
}
struct Vertex {
  intvec nxt;
  int vdist = -1, udist = -1;
};
int N, U, V, ans;
vector<Vertex> ver;
void input() {
  cin >> N >> U >> V;
  U--, V--;
  ver.resize(N);
  for (int i = 0; i < N - 1; i++) {
    int A, B;
    cin >> A >> B;
    A--, B--;
    ver[A].nxt.push_back(B);
    ver[B].nxt.push_back(A);
  }
}
void solve() {
  intq q;
  q.push(V);
  ver[V].vdist = 0;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int i = 0; i < ver[now].nxt.size(); i++) {
      int npos = ver[now].nxt[i];
      if (ver[npos].vdist >= 0) continue;
      ver[npos].vdist = ver[now].vdist + 1;
      q.push(npos);
    }
  }
  q.push(U);
  ver[U].udist = 0;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    int ud = ver[now].udist, vd = ver[now].vdist;
    if (ud < vd) {
      chmax(ans, ud + (vd - ud) / 2);
    }
    for (int i = 0; i < ver[now].nxt.size(); i++) {
      int npos = ver[now].nxt[i];
      if (ver[npos].udist >= 0) continue;
      ver[npos].udist = ver[now].udist + 1;
      q.push(npos);
    }
  }
  cout << ans << endl;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int t = 1;
  while (t) {
    input();
    solve();
    t--;
  }
}
