#include <bits/stdc++.h>
static const long long mod = 1000000007;
static const long long INF = 1000000000000000000LL;
using namespace std;
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  --u;
  --v;
  vector<vector<int>> G(N);
  for (long long 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> aoki(N, N + 100);
  vector<int> taka(N, N + 100);
  aoki[v] = 0;
  queue<int> que;
  que.push(v);
  int from, to;
  while (!que.empty()) {
    from = que.front();
    que.pop();
    for (int i = 0; i < G[from].size(); ++i) {
      to = G[from][i];
      if (aoki[from] + 1 < aoki[to]) {
        aoki[to] = aoki[from] + 1;
        que.push(to);
      }
    }
  }
  taka[u] = 0;
  que.push(u);
  while (!que.empty()) {
    from = que.front();
    que.pop();
    for (int i = 0; i < G[from].size(); ++i) {
      to = G[from][i];
      if (taka[from] + 1 < taka[to] && taka[from] + 1 < aoki[to]) {
        taka[to] = taka[from] + 1;
        que.push(to);
      }
    }
  }
  int res = 0;
  int tmp;
  for (long long i = 0; i < (N); i++) {
    if (taka[i] > N) continue;
    tmp = aoki[i];
    if (taka[i] % 2 != aoki[i] % 2) --tmp;
    res = max(res, tmp);
  }
  cout << res << endl;
  return 0;
}
