#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
int dist[100005] = {};
int dist2[100005] = {};
int paint[100005] = {};
int dept[100005] = {};
vector<int> e[100005];
int g = 0;
int dfs2(int u, int p, int dep) {
  if (dep >= dist[u]) {
    dist2[u] = -1e6;
    return dist2[u];
  }
  dist2[u] = dist[u];
  dept[u] = dep;
  for (auto s : e[u]) {
    if (s != p) dist2[u] = max(dist2[u], dfs2(s, u, dep + 1));
  }
  return dist2[u];
}
void dfs(int u, int p, int c) {
  dist[u] = c;
  for (auto s : e[u]) {
    if (s != p) dfs(s, u, c + 1);
  }
}
void solve(long long N, long long u, long long v, std::vector<long long> A,
           std::vector<long long> B) {
  for (lli i = 0; i < (N); i++) {
    A[i]--, B[i]--;
    e[A[i]].push_back(B[i]);
    e[B[i]].push_back(A[i]);
    dist[i] = -1e6;
    dist2[i] = -1e6;
  }
  u--, v--;
  g = u;
  dist[v] = 0;
  dfs(v, -1, 0);
  dfs2(u, -1, 0);
  for (lli i = 0; i < (N); i++) cerr << dist2[i] << " ";
  cerr << "\n";
  for (lli i = 0; i < (N); i++) cerr << dist[i] << " ";
  cerr << endl;
  int turn = 0;
  int aok = 0;
  int di = dist[u];
  while (di > aok) {
    if (turn) {
      aok++;
    } else {
      vector<pair<int, int>> cand;
      for (auto s : e[u]) {
        if (dept[s] > dept[u]) {
          cand.push_back(make_pair(dist2[s] + 1e6, -dist[s]));
        } else {
          cand.push_back(make_pair(dist2[s], -dist[s]));
        }
      }
      int nxt = max_element(cand.begin(), cand.end()) - cand.begin();
      u = e[u][nxt];
      di = dist[u];
    }
    cerr << u << " " << di << " " << aok << " " << turn << endl;
    turn ^= 1;
  }
  cout << aok << endl;
}
int main() {
  int a;
  long long N;
  scanf("%lld", &N);
  long long u;
  scanf("%lld", &u);
  long long v;
  scanf("%lld", &v);
  std::vector<long long> A(N - 1);
  std::vector<long long> B(N - 1);
  for (int i = 0; i < N - 1; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, u, v, std::move(A), std::move(B));
  return 0;
}
