#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MOD2 = 998244353;
const long long MOD3 = 1812447359;
const long long INF = 1ll << 62;
const double PI = 2 * asin(1);
void yes() { printf("yes\n"); }
void no() { printf("no\n"); }
void Yes() { printf("Yes\n"); }
void No() { printf("No\n"); }
void YES() { printf("YES\n"); }
void NO() { printf("NO\n"); }
int N, U, V;
vector<int> Graph[int(1e5 + 5)];
int DistU[int(1e5 + 5)], DistV[int(1e5 + 5)];
int main() {
  cin >> N >> U >> V;
  for (int i = 0; i < N - 1; i++) {
    int A, B;
    cin >> A >> B;
    Graph[A].push_back(B);
    Graph[B].push_back(A);
  }
  fill(DistV, DistV + N + 1, -1);
  queue<int> que;
  que.push(V);
  DistV[V] = 0;
  while (!que.empty()) {
    int Q = que.front();
    que.pop();
    for (int next : Graph[Q]) {
      if (DistV[next] != -1) continue;
      DistV[next] = DistV[Q] + 1;
      que.push(next);
    }
  }
  int ans = 0;
  fill(DistU, DistU + N + 1, -1);
  que.push(U);
  DistU[U] = 0;
  while (!que.empty()) {
    int Q = que.front();
    que.pop();
    for (int next : Graph[Q]) {
      if (DistU[next] != -1) continue;
      DistU[next] = DistU[Q] + 1;
      if (DistU[next] <= DistV[next]) {
        que.push(next);
        ans = max(ans, DistU[next]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
