#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, t, a;
  cin >> n >> t >> a;
  --t;
  --a;
  vector<int> roots;
  vector<vector<int>> g(n);
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    if (y == a) {
      swap(x, y);
    }
    if (x == a) {
      roots.push_back(y);
    } else {
      g[x].push_back(y);
      g[y].push_back(x);
    }
  }
  vector<int> d(n, 0);
  vector<int> p(n);
  function<void(int, int, int)> Dfs = [&](int v, int pv, int par) {
    p[v] = par;
    for (int u : g[v]) {
      if (u == pv) {
        continue;
      }
      d[u] = d[v] + 1;
      Dfs(u, v, par);
    }
  };
  for (int v : roots) {
    Dfs(v, -1, v);
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] == p[t]) {
      mx = max(mx, d[i]);
    }
  }
  cout << mx << '\n';
  return 0;
}
