#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int maxn = 100009;
const int inf = 100000009;
int par[maxn], lev[maxn];
vector<int> g[maxn];
int jk;
void dfs(int p, int pa, int le) {
  par[p] = pa;
  lev[p] = le;
  for (int i = 0; i < g[p].size(); ++i) {
    int tmp = g[p][i];
    if (tmp != pa) dfs(tmp, p, le + 1);
  }
}
int kl = 0;
void hj(int p) {
  kl = max(kl, lev[p]);
  for (int i = 0; i < g[p].size(); ++i) {
    int tmp = g[p][i];
    if (par[p] != tmp) hj(tmp);
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  int gh = u;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(v, -1, 0);
  int tmp = (lev[u] - 1) / 2;
  int fg = tmp;
  while (tmp) u = par[u], --tmp;
  hj(u);
  if (fg)
    cout << fg + kl - lev[u];
  else {
    cout << kl - 1;
  }
  return 0;
}
