#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
void buff() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
constexpr ll MOD = 1e9 + 7;
inline ll pow_mod(ll a, ll b, ll mod = MOD) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
  }
  return res;
}
int n, u, v, a, b;
vector<vector<int> > g;
void explore(int root, vector<int>& dist, int parent) {
  for (const auto& viz : g[root]) {
    if (dist[viz] == -1 && viz != parent) {
      dist[viz] = dist[root] + 1;
      explore(viz, dist, root);
    }
  }
}
int main() {
  buff();
  cin >> n;
  g.resize(n);
  cin >> u >> v;
  --u;
  --v;
  for (int i = 0; i < n - 1; ++i) {
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> dist_u(n, -1);
  dist_u[u] = 0;
  explore(u, dist_u, -1);
  vector<int> dist_v(n, -1);
  dist_v[v] = 0;
  explore(v, dist_v, -1);
  int st_dist = dist_u[v];
  int large_delay = 0;
  for (int i = 0; i < n; ++i) {
    if (dist_v[i] - dist_u[i] == st_dist) {
      large_delay = max(large_delay, dist_u[i]);
    }
  }
  function<int(int)> calc = [&](int cur_dist) {
    if (cur_dist == 0) return 0;
    if (cur_dist == 1) return 0;
    if (cur_dist == 2) return 1;
    return 2 + calc((cur_dist - 2));
  };
  int best = calc(st_dist);
  for (int i = 0; i < n; ++i) {
    if (dist_u[i] < dist_v[i]) {
      int cur = dist_u[i];
      best = max(best, cur + calc(dist_v[i] - dist_u[i]));
    }
  }
  cout << best << '\n';
  return 0;
}
