#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
int main() {
  int N, u, v;
  std::cin >> N >> u >> v;
  --u;
  --v;
  std::vector<std::vector<int>> from(N);
  for (int(i) = 0; i < (N - 1); ++(i)) {
    int A, B;
    std::cin >> A >> B;
    --A;
    --B;
    from[A].push_back(B);
    from[B].push_back(A);
  }
  std::vector<int> du(N, -1), dv(N, -1);
  du[u] = 0;
  dv[v] = 0;
  std::queue<int> q;
  q.push(u);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int y : from[x]) {
      if (du[y] >= 0) {
        continue;
      }
      du[y] = du[x] + 1;
      q.push(y);
    }
  }
  q.push(v);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int y : from[x]) {
      if (dv[y] >= 0) {
        continue;
      }
      dv[y] = dv[x] + 1;
      q.push(y);
    }
  }
  int ans = 0;
  for (int p = 0; p < N; ++p) {
    if (du[p] >= dv[p]) {
      continue;
    }
    ans = std::max(ans, du[p] + (dv[p] - du[p]) / 2);
  }
  std::cout << ans << '\n';
}
