#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> depth(N, -1);
  depth[v] = 0;
  int max_d = 0;
  std::queue<int> q;
  q.push(v);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int y : from[x]) {
      if (depth[y] >= 0) {
        continue;
      }
      depth[y] = depth[x] + 1;
      max_d = std::max(max_d, depth[y]);
      q.push(y);
    }
  }
  int px = 0;
  int py = depth[u];
  int ans = 0;
  while (px != py) {
    if (py + 1 <= max_d) {
      ++py;
    } else {
      --py;
    }
    if (px == py) {
      break;
    }
    ++px;
    ++ans;
  }
  std::cout << ans << '\n';
}
