#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 U[int(1e5 + 5)], V[int(1e5 + 5)];
int Solve() {
  fill(U, U + N + 1, -1);
  U[u] = 0;
  queue<int> que;
  que.push(u);
  while (!que.empty()) {
    int Q = que.front();
    que.pop();
    for (int next : Graph[Q]) {
      if (U[next] != -1) continue;
      U[next] = U[Q] + 1;
      que.push(next);
    }
  }
  fill(V, V + N + 1, -1);
  que.push(v);
  V[v] = 0;
  while (!que.empty()) {
    int Q = que.front();
    que.pop();
    for (int next : Graph[Q]) {
      if (V[next] != -1) continue;
      V[next] = V[Q] + 1;
      que.push(next);
    }
  }
  return 0;
}
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);
  }
  Solve();
  int ans = U[v] / 2;
  for (int i = 1; i <= N; i++) {
    if (U[i] + V[u] == V[i]) {
      ans = max(ans, V[u] - 1);
    } else if (U[i] < V[i]) {
      ans = max(ans, V[i] - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
