#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> e[N];
vector<int> fi, se;
int x, y, lc, a, b;
int n, u, v, par[N], dep[N], mx, dis;
void dfs(int now, int fa, int d) {
  par[now] = fa;
  dep[now] = d;
  for (int i = 0; i < e[now].size(); ++i) {
    int nex = e[now][i];
    if (nex == fa) continue;
    dfs(nex, now, d + 1);
  }
}
void dfs2(int u, int fa, int d) {
  par[u] = fa;
  dep[u] = d;
  mx = max(mx, dep[u]);
  for (int v : e[u]) {
    if (v == fa) continue;
    if (u == a && v == b) continue;
    if (u == b && v == a) continue;
    dfs2(v, u, d + 1);
  }
}
void lca(int u, int v) {
  int a = u, b = v;
  if (dep[u] < dep[v]) swap(u, v);
  for (; dep[u] != dep[v]; u = par[u])
    ;
  if (u == v) {
    lc = u;
    dis = dep[a] + dep[b] - 2 * dep[u];
    return;
  }
  for (; u != v; u = par[u], v = par[v])
    ;
  if (u == v) {
    lc = u;
    dis = dep[a] + dep[b] - 2 * dep[u];
    return;
  }
}
int main() {
  scanf("%d%d%d", &n, &u, &v);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1, 0, 0);
  lca(u, v);
  if (dis == 2)
    puts("1");
  else {
    a = v, b = u;
    for (; b != lc; b = par[b]) fi.push_back(b);
    for (; a != lc; a = par[a]) se.push_back(a);
    reverse(se.begin(), se.end());
    fi.push_back(lc);
    for (int v : se) fi.push_back(v);
    int id = (dis - 1) / 2;
    a = fi[id];
    b = fi[id + 1];
    memset(dep, 0, sizeof dep);
    dfs2(a, 0, 0);
    printf("%d\n", id + mx);
  }
  return 0;
}
