#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, su, sv;
  cin >> n >> su >> sv;
  su--;
  sv--;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int fromU = -1;
  int fromV = -1;
  int ans = 0;
  vector<int> path;
  function<void(int, int)> dfs;
  dfs = [&](int v, int p) {
    path.push_back(v);
    if (v == sv) {
      int j = (path.size() - 2) / 2;
      ans = j;
      fromU = path[j];
      fromV = path[j + 1];
      return;
    } else {
      for (int u : g[v]) {
        if (u != p) {
          dfs(u, v);
        }
      }
    }
    path.pop_back();
  };
  dfs(su, -1);
  int mx = 0;
  vector<int> d(n, -1);
  d[fromU] = 0;
  vector<int> q = {fromU};
  for (int qi = 0; qi < q.size(); qi++) {
    int v = q[qi];
    for (int u : g[v]) {
      if (d[u] == -1 && u != fromV) {
        d[u] = d[v] + 1;
        mx = max(d[u], mx);
        q.push_back(u);
      }
    }
  }
  ans += mx;
  cout << ans << endl;
}
