#include <bits/stdc++.h>
using namespace std;
long long N, u, v;
vector<long long> G[101010];
vector<long long> distA(101010, -1), distB(101010, -1);
signed main() {
  cin >> N >> u >> v;
  u--, v--;
  for (long long i = 0; i < N - 1; i++) {
    long long A, B;
    cin >> A >> B;
    A--, B--;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  queue<long long> que;
  que.push(u);
  while (!que.empty()) {
    long long v = que.front();
    que.pop();
    for (long long x : G[v]) {
      if (distA[x] != -1) continue;
      distA[x] = distA[v] + 1;
      que.push(x);
    }
  }
  que.push(v);
  while (!que.empty()) {
    long long v = que.front();
    que.pop();
    for (long long x : G[v]) {
      if (distB[x] != -1) continue;
      distB[x] = distB[v] + 1;
      que.push(x);
    }
  }
  bool flag = true;
  long long ansP = 0, mx = 0, pre = 0;
  for (long long i = 0; i < N; i++) {
    if (distA[i] < distB[i]) {
      if (mx < distA[i]) {
        mx = distA[i];
        pre = i;
        ansP = pre;
      }
      flag = false;
    }
  }
  if (flag) {
    cout << 1 << endl;
    return 0;
  }
  cout << distB[ansP] << endl;
  return 0;
}
