#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF = (1LL << 62);
const double inf = pow(10, 10);
double pi = 3.141592653589793;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int ddx[8] = {1, 0, -1, -1, -1, 0, 1, 1};
const int ddy[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int main() {
  long long N, V, U;
  cin >> N >> V >> U;
  V--;
  U--;
  vector<long long> G[N];
  for (int i = 0; i < N - 1; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<long long> d_V(N, -1);
  d_V[V] = 0;
  queue<long long> que;
  que.push(V);
  while (!que.empty()) {
    long long u = que.front();
    que.pop();
    for (int i = 0; i < G[u].size(); i++) {
      long long next = G[u][i];
      if (d_V[next] != -1) continue;
      d_V[next] = d_V[u] + 1;
      que.push(next);
    }
  }
  vector<long long> d_U(N, -1);
  d_U[U] = 0;
  queue<long long> que2;
  que2.push(U);
  while (!que2.empty()) {
    long long u = que2.front();
    que2.pop();
    for (int i = 0; i < G[u].size(); i++) {
      long long next = G[u][i];
      if (d_U[next] != -1) continue;
      d_U[next] = d_U[u] + 1;
      que2.push(next);
    }
  }
  long long num = 0;
  for (int i = 0; i < N; i++) {
    if (d_U[i] - d_V[i] > 0) num = max(num, (d_V[i] + d_U[i]) / 2);
  }
  cout << num << endl;
}
