#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  u--, v--;
  vector<vector<int>> E(N);
  for (int i = 0; i < N - 1; i++) {
    int A, B;
    cin >> A >> B;
    E[A - 1].push_back(B - 1);
    E[B - 1].push_back(A - 1);
  }
  int md = 0;
  int td = 0;
  function<void(int, int, int)> f = [&](int c, int p, int d) {
    if (c == u) td = d;
    md = max(md, d);
    for (int e : E[c])
      if (e != p) f(e, c, d + 1);
  };
  f(v, -1, 0);
  int a = 0;
  int t = td;
  while (true) {
    if (t < md)
      t++;
    else
      t--;
    if (a == t) {
      cout << a << endl;
      break;
    }
    a++;
    if (a == t) {
      cout << a << endl;
      break;
    }
  }
}
