#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007;
long long modx(long long a) { return (a % MOD + MOD) % MOD; }
long long times(long long a, long long b) { return modx(modx(a) * modx(b)); }
long long add(long long a, long long b) { return modx(modx(a) + modx(b)); }
long long sub(long long a, long long b) {
  return modx(MOD + modx(a) - modx(b));
}
long long fastExp(long long base, long long exp) {
  if (exp == 0LL) {
    return 1LL;
  }
  if (exp % 2 == 0) {
    return fastExp(times(base, base), exp / 2);
  } else {
    return times(base, fastExp(times(base, base), exp / 2));
  }
}
const int MAXN = (int)1e5 + 1;
int N, depth[MAXN], par[MAXN][17], maxDist;
vector<int> g[MAXN];
void dfs(int x) {
  for (int i = 1; i < 17; i++) par[x][i] = par[par[x][i - 1]][i - 1];
  for (int i = 0; i < g[x].size(); i++) {
    if (g[x][i] != par[x][0]) {
      par[g[x][i]][0] = x;
      depth[g[x][i]] = depth[x] + 1;
      dfs(g[x][i]);
    }
  }
}
int lca(int x, int y) {
  int i = 16, j = 16;
  if (depth[y] > depth[x]) swap(x, y);
  while (depth[x] > depth[y]) {
    if (depth[x] - depth[y] >= (1 << i)) x = par[x][i];
    i--;
  }
  while (x != y) {
    if (j == -1) break;
    if (par[x][j] != par[y][j]) x = par[x][j], y = par[y][j];
    j--;
  }
  if (x == y) return x;
  return par[x][0];
}
void farthest(int a, int dist) {
  maxDist = max(maxDist, dist);
  for (int i = 0; i < g[a].size(); i++) {
    if (depth[g[a][i]] <= depth[a]) {
      continue;
    }
    farthest(g[a][i], dist + 1);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(v);
  int ans = depth[u] / 2;
  int newV = u;
  for (int i = 0; i < (depth[u] - depth[u] / 2); i++) {
    newV = par[newV][0];
  }
  farthest(newV, 0);
  ans += (maxDist);
  cout << ans;
  return 0;
}
