#include <bits/stdc++.h>
using namespace std;
int N;
vector<set<int>> E;
map<pair<int, int>, int> NM;
int next(int T, int A) {
  if (NM.count(make_pair(T, A))) {
    return NM.at(make_pair(T, A));
  }
  if (E[A].count(T)) {
    NM[make_pair(T, A)] = T;
    return T;
  }
  vector<bool> C(N, false);
  queue<int> Q;
  C[T] = true;
  Q.push(T);
  while (1) {
    int t = Q.front();
    Q.pop();
    for (int i : E[t]) {
      if (E[A].count(i)) {
        NM[make_pair(T, A)] = i;
        return i;
      }
      if (!C[i]) {
        Q.push(i);
        C[i] = true;
      }
    }
  }
}
int rec(int T, int A) {
  bool flg = true;
  for (int i : E[T]) {
    if (i != A) flg = false;
  }
  if (flg) {
    return 0;
  }
  flg = true;
  for (int i : E[T]) {
    if (!E[i].count(A)) flg = false;
  }
  if (flg) {
    return 1;
  }
  int res = 0;
  for (int i : E[T]) {
    if ((!E[A].count(i)) && (A != i)) {
      res = max(res, rec(i, next(i, A)));
    }
  }
  return res + 1;
}
int main() {
  set<int> s;
  int u, v;
  cin >> N >> u >> v;
  for (int i = 0; i < N; i++) {
    E.push_back(s);
  }
  for (int i = 0; i < N - 1; i++) {
    int A, B;
    cin >> A >> B;
    E[A - 1].insert(B - 1);
    E[B - 1].insert(A - 1);
  }
  cout << rec(u - 1, v - 1);
}
