#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int N;
  cin >> N;
  int u, v;
  cin >> u >> v;
  u--;
  v--;
  vector<vector<int>> t(N);
  int a, b;
  int ans = 0;
  for (int i = 0; i < (N - 1); i++) {
    cin >> a >> b;
    a--;
    b--;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  vector<int> du(N, -1);
  vector<int> dv(N, -1);
  queue<int> qu, qv;
  qu.push(u);
  du[u] = 0;
  while (!qu.empty()) {
    int now = qu.front();
    qu.pop();
    for (int i = 0; i < ((int)t[now].size()); i++) {
      if (du[t[now][i]] >= 0) continue;
      qu.push(t[now][i]);
      du[t[now][i]] = du[now] + 1;
    }
  }
  qv.push(v);
  dv[v] = 0;
  while (!qv.empty()) {
    int now = qv.front();
    qv.pop();
    for (int i = 0; i < ((int)t[now].size()); i++) {
      if (dv[t[now][i]] >= 0) continue;
      qv.push(t[now][i]);
      dv[t[now][i]] = dv[now] + 1;
    }
  }
  vector<int> yuyo(N, -1);
  for (int i = 0; i < (N); i++) {
    yuyo[i] = dv[i] - du[i];
  }
  for (int i = 0; i < (N); i++) {
    if (yuyo[i] > 0) ans = max(ans, yuyo[i] / 2 + du[i]);
  }
  cout << ans << endl;
  return 0;
}
