#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
std::vector<int> G[maxn];
int h[maxn], f[maxn], vis[maxn];
void dfs(int u, int fa) {
  h[u] = 1;
  f[u] = fa;
  for (int i : G[u]) {
    if (i == fa) continue;
    dfs(i, u);
    h[u] = max(h[i] + 1, h[u]);
  }
}
int main(int argc, char const *argv[]) {
  int n, u, v;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> v >> u;
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(u, 0);
  int x = (-1 + h[u] - h[v]) / 2;
  int res = h[u] - h[v] - 1;
  for (int i = 0; i < x; ++i) {
    res = max(res, h[u] - h[v] - 1);
    v = f[v];
  }
  cout << res << endl;
  return 0;
}
