#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using seika = string;
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;
inline void print() { cout << endl; }
template <typename First, typename... Rest>
void print(const First &first, const Rest &...rest) {
  cout << first << ' ';
  print(rest...);
}
void solve() {
  int n, u, v;
  cin >> n >> u >> v;
  u--, v--;
  yukari<int> g(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<int> q;
  akari<int> ds(n, -1), ds2(n, -1);
  ds[u] = 0;
  q.push(u);
  while (!q.empty()) {
    int curv = q.front();
    q.pop();
    for (int nv : g[curv]) {
      if (ds[nv] != -1) {
        continue;
      }
      ds[nv] = ds[curv] + 1;
      q.push(nv);
    }
  }
  ds2[v] = 0;
  q.push(v);
  while (!q.empty()) {
    int curv = q.front();
    q.pop();
    for (int nv : g[curv]) {
      if (ds2[nv] != -1) {
        continue;
      }
      ds2[nv] = ds2[curv] + 1;
      q.push(nv);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (ds[i] < ds2[i]) {
      ans = max(ans, ds[i] + (ds2[i] - ds[i]) / 2);
    }
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
