#include <bits/stdc++.h>
using namespace std;
long long n, u, v;
long long disu[123321], disv[123321];
bool bu[123321], bv[123321];
vector<long long> v1[123321];
void fu(long long u1) {
  for (long long i : v1[u1]) {
    if (bu[i] == 0) {
      bu[i] = 1;
      disu[i] = disu[u1] + 1;
      fu(i);
    }
  }
}
void fv(long long u1) {
  for (long long i : v1[u1]) {
    if (bv[i] == 0) {
      bv[i] = 1;
      disv[i] = disv[u1] + 1;
      fv(i);
    }
  }
}
signed main() {
  cin >> n >> u >> v;
  for (long long i = 0; i < (n - 1); i++) {
    long long a, b;
    cin >> a >> b;
    v1[a].push_back(b);
    v1[b].push_back(a);
  }
  bu[u] = 1;
  fu(u);
  bv[v] = 1;
  fv(v);
  long long dv = 0, du = 0;
  for (long long i = 1; i <= (n); i++)
    if (disu[i] < disv[i] && dv < disv[i]) {
      du = disu[i];
      dv = disv[i];
    }
  if (du % 2 == dv % 2) {
    cout << (du == 0 && dv == 2 ? 1 : dv) << endl;
  } else
    cout << dv - 1 << endl;
}
