#include <bits/stdc++.h>
using namespace std;
signed main(signed argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, u, v;
  cin >> n >> u >> v;
  vector<vector<long long>> e(n + 1);
  for (long long i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  vector<long long> memo_v(n + 1);
  vector<bool> vec(n + 1, false);
  queue<long long> que;
  que.push(v);
  vec[v] = true;
  memo_v[v] = 0;
  while (!que.empty()) {
    long long it = que.front();
    que.pop();
    for (long long i = 0; i < e[it].size(); i++) {
      if (vec[e[it][i]]) continue;
      vec[e[it][i]] = true;
      memo_v[e[it][i]] = memo_v[it] + 1;
      que.push(e[it][i]);
    }
  }
  vector<long long> memo_u(n + 1);
  vec = vector<bool>(n + 1, false);
  que.push(u);
  vec[u] = true;
  memo_u[u] = 0;
  while (!que.empty()) {
    long long it = que.front();
    que.pop();
    for (long long i = 0; i < e[it].size(); i++) {
      if (vec[e[it][i]]) continue;
      vec[e[it][i]] = true;
      memo_u[e[it][i]] = memo_u[it] + 1;
      que.push(e[it][i]);
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (e[i + 1].size() == 1) {
      if (memo_v[i + 1] - memo_u[i + 1] > 0) {
        ans = max(ans, (memo_v[i + 1] - memo_u[i + 1]) / 2 + memo_u[i + 1]);
      }
    }
  }
  cout << ans << endl;
}
