#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const long long INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, A, B;
  cin >> N >> A >> B;
  A--;
  B--;
  vector<vector<int>> g(N);
  vector<int> da(N), db(N);
  da[A] = 1;
  db[B] = 1;
  for (int i = 0; i < (N - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<int> q, q2;
  q.push(A);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int i = 0; i < g[now].size(); i++) {
      int next = g[now][i];
      if (da[next]) continue;
      da[next] = da[now] + 1;
      q.push(next);
    }
  }
  q.push(B);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int i = 0; i < g[now].size(); i++) {
      int next = g[now][i];
      if (db[next]) continue;
      db[next] = db[now] + 1;
      q.push(next);
    }
  }
  int mx = 0;
  int p = -1;
  for (int i = 0; i < (N); i++) {
    if (da[i] < db[i]) {
      mx = max(mx, da[i]);
      p = i;
    }
  }
  if ((da[p] + db[p]) % 2 == 1)
    cout << mx - 1 << endl;
  else
    cout << mx << endl;
}
