#include <bits/stdc++.h>
using namespace std;
long long int N, u, v;
long long int A[100005], B[100005];
vector<long long int> edges[100005];
long long int d[100005];
long long int d2[100005];
long long int up[100005];
long long int L = 0;
signed main() {
  scanf("%lld %lld %lld", &N, &u, &v);
  u--;
  v--;
  for (long long int i = 0; i < N - 1; i++) {
    scanf("%lld %lld", &A[i], &B[i]);
    A[i]--;
    B[i]--;
    edges[A[i]].push_back(B[i]);
    edges[B[i]].push_back(A[i]);
  }
  long long int ans = 0;
  queue<long long int> q;
  queue<long long int> q2;
  long long int dist = 0;
  q.push(v);
  for (long long int i = 0; i < N; i++) {
    d[i] = -1;
    d2[i] = -1;
  }
  while (!q.empty()) {
    long long int from = q.front();
    q.pop();
    d[from] = dist;
    for (long long int i = 0; i < edges[from].size(); i++) {
      if (d[edges[from][i]] == -1) q2.push(edges[from][i]);
      up[edges[from][i]] = from;
    }
    if (q.empty()) {
      swap(q, q2);
      dist++;
    }
  }
  queue<long long int> q3;
  queue<long long int> q4;
  long long int dist2 = 0;
  q3.push(u);
  while (!q3.empty()) {
    long long int from = q3.front();
    q3.pop();
    d2[from] = dist2;
    for (long long int i = 0; i < edges[from].size(); i++) {
      if (d2[i] == -1) q4.push(edges[from][i]);
    }
    if (q3.empty()) {
      swap(q3, q4);
      dist2++;
    }
  }
  for (long long int i = 0; i < N; i++) {
    if (d[i] >= d2[i] && d[i] > ans) ans = d[i];
  }
  printf("%lld\n", ans - 1);
  return 0;
}
