#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, u, v;
  scanf("%d %d %d", &n, &u, &v);
  u--;
  v--;
  vector<vector<int> > nei(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    nei[a].push_back(b);
    nei[b].push_back(a);
  }
  if (u == v) {
    cout << 0 << endl;
  }
  set<int> tnow;
  set<int> anow;
  tnow.insert(u);
  anow.insert(v);
  vector<int> aoki(n, 0);
  aoki[v] = 1;
  int cnt = 0;
  while (1) {
    set<int> tnext = set<int>();
    for (int i : tnow) {
      for (int j : nei[i]) {
        if (aoki[j] == 0) {
          tnext.insert(j);
        }
      }
    }
    if ((int)tnext.size() == 0) {
      cout << cnt << endl;
      return 0;
    }
    cnt++;
    tnow = tnext;
    set<int> anext = set<int>();
    for (int i : anow) {
      for (int j : nei[i]) {
        if (aoki[j] == 0) anext.insert(j);
        aoki[j] = 1;
        auto p = tnow.find(j);
        if (p != tnow.end()) {
          tnow.erase(p);
        }
      }
    }
    if ((int)tnow.size() == 0) {
      cout << cnt << endl;
      return 0;
    }
    anow = anext;
  }
  return 0;
}
