#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
template <class T>
T gcd(T a, T b) {
  return ((b == 0) ? a : gcd(b, a % b));
}
int n, u, v;
int ans = 0;
vector<int> g[100005];
int U[100005];
int V[100005];
void dfs(int cur, int prev, int cnt, int f) {
  if (f == 1) U[cur] = cnt;
  if (f == 2) V[cur] = cnt;
  for (int nxt : g[cur])
    if (nxt != prev) dfs(nxt, cur, cnt + 1, f);
}
void dfs1(int cur, int prev) {
  if (V[cur] <= U[cur]) return;
  ans = max(ans, U[cur] + (V[cur] - U[cur]) / 2);
  for (int nxt : g[cur])
    if (nxt != prev) dfs1(nxt, cur);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> u >> v;
  u--, v--;
  for (int i = 0; i < (int)(n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(u, -1, 0, 1);
  dfs(v, -1, 0, 2);
  dfs1(u, -1);
  cout << ans << endl;
  return 0;
}
