#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void cmps(vector<long long> &v, long long &i) {
  i = lower_bound(v.begin(), v.end(), i) - v.begin();
}
constexpr long long mod = 1e9 + 7;
constexpr long long inf = 3e18;
long long mod_pow(long long x, long long y, long long m = mod) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x % m;
    y >>= 1;
    x = x * x % m;
  }
  return res;
}
long long perm[1000001], inv[1000001];
void init_perm() {
  perm[0] = 1;
  for (long long i = 1; i < 1000001; i++) perm[i] = perm[i - 1] * i % mod;
  inv[1000000] = mod_pow(perm[1000000], mod - 2);
  for (long long i = 999999; i >= 0; i--) {
    inv[i] = inv[i + 1] * (i + 1) % mod;
  }
}
long long nCk(long long x, long long y) {
  if (x < y) return 0;
  return perm[x] * inv[x - y] % mod * inv[y] % mod;
}
long long N, u, v;
long long depth[100005], mx[100005], par[100005];
vector<long long> G[100005];
long long dfs(long long x, long long p) {
  mx[x] = depth[x];
  for (long long i : G[x])
    if (i != p) {
      depth[i] = depth[x] + 1;
      par[i] = x;
      chmax(mx[x], dfs(i, x));
    }
  return mx[x];
}
signed main() {
  cin >> N >> u >> v;
  u--;
  v--;
  for (long long i = 0; i < N - 1; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(v, v);
  long long now = u, ans = -inf;
  while (depth[now] >= depth[u] / 2 + 1) {
    for (long long i : G[now])
      if (i != par[i]) chmax(ans, mx[i]);
    now = par[now];
  }
  cout << ans - 1 << endl;
}
