#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
inline int std_in(int& a) { return scanf("%d", &a); }
auto pint_compare = [](pint x, pint y) -> bool { return (x.first < y.first); };
const int MOD = 1000000007;
int N, u, v;
int aoki[100000], takahashi[100000];
vector<int> adj[100000];
bool visited[100000];
void dfs_aoki(int index, int depth) {
  if (visited[index]) return;
  aoki[index] = depth;
  visited[index] = true;
  for (int next : adj[index]) {
    dfs_aoki(next, depth + 1);
  }
}
void dfs_takahashi(int index, int depth) {
  if (visited[index]) return;
  takahashi[index] = depth;
  visited[index] = true;
  for (int next : adj[index]) {
    dfs_takahashi(next, depth + 1);
  }
}
signed main() {
  cin >> N >> u >> v;
  u--;
  v--;
  int A, B;
  for (int(i) = 0; (i) < (N - 1); ++(i)) {
    cin >> A >> B;
    A--;
    B--;
    adj[A].push_back(B);
    adj[B].push_back(A);
  }
  for (int(i) = 0; (i) < (N); ++(i)) visited[i] = false;
  dfs_aoki(v, 0);
  for (int(i) = 0; (i) < (N); ++(i)) visited[i] = false;
  dfs_takahashi(u, 0);
  int t, a;
  if (aoki[u] % 2 == 0)
    t = 1, a = 1;
  else
    t = 1, a = 0;
  for (int(i) = 0; (i) < (N); ++(i)) {
    if (takahashi[i] < aoki[i] && t < takahashi[i]) {
      a = aoki[i];
      t = takahashi[i];
    }
  }
  if (a == t) {
    a = N, t = N;
    for (int(i) = 0; (i) < (N); ++(i)) {
      if (takahashi[i] == aoki[i] && aoki[i] < a) {
        a = aoki[i];
        t = takahashi[i];
      }
    }
  }
  if ((a - t) % 2 == 0)
    cout << (t + (a - t) / 2) << "\n";
  else
    cout << (t - 1 + (a - t + 1) / 2) << "\n";
  return 0;
}
