#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;
void dfs(int v, int p, int d, vector<vector<int>> &G, vector<int> &dist) {
  dist[v] = d;
  for (auto nv : G[v]) {
    if (nv == p) continue;
    dfs(nv, v, d + 1, G, dist);
  }
}
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  u--, v--;
  vector<vector<int>> G(N);
  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);
  }
  vector<int> udist(N);
  vector<int> vdist(N);
  dfs(u, -1, 0, G, udist);
  dfs(v, -1, 0, G, vdist);
  int dest = 0, destd = 0;
  for (int(i) = 0; (i) < (N); (i)++) {
    if (udist[i] < vdist[i]) {
      if (destd < udist[i]) {
        dest = i;
        destd = udist[i];
      }
    }
  }
  if ((vdist[dest] - udist[dest]) % 2 == 1) {
    cout << vdist[dest] - 1 << endl;
  } else {
    cout << vdist[dest] << endl;
  }
  return 0;
}
