#include <bits/stdc++.h>
using namespace std;
vector<int> used;
vector<vector<int>> g;
void dfs(int cur, int ch, vector<int> &h) {
  h[cur] = ch;
  used[cur] = 1;
  for (auto t : g[cur]) {
    if (!used[t]) {
      dfs(t, ch + 1, h);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  int a, b;
  cin >> n >> a >> b;
  a--;
  b--;
  used.resize(n);
  g.resize(n);
  for (int i = 0; i + 1 < n; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> ha(n);
  vector<int> hb(n);
  dfs(a, 0, ha);
  fill(used.begin(), used.end(), 0);
  dfs(b, 0, hb);
  int mxh = -1;
  int len = -1;
  for (int i = 0; i < n; i++) {
    if (hb[i] > ha[i]) {
      if (ha[i] > mxh) {
        mxh = ha[i];
        len = hb[i] - ha[i];
      }
    }
  }
  if (len == 0) {
    cout << mxh << endl;
    return 0;
  }
  int add = mxh;
  int ca = len;
  int cb = 0;
  int ans = 0;
  for (int i = 0;; i++) {
    if (i & 1) {
      ca--;
      ans++;
    } else {
      cb ^= 1;
    }
    if (ca == cb) {
      cout << ans + add << endl;
      return 0;
    }
  }
}
