#include <bits/stdc++.h>
using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  Graph G(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    G.at(a - 1).push_back(b - 1);
    G.at(b - 1).push_back(a - 1);
  }
  bitset<100000> Taka, Aoki, tmp;
  Taka.set(u);
  Aoki.set(v);
  for (int i = 0; i < n; i++) {
    tmp.reset();
    for (int j = 0; j < n; j++) {
      if (Taka.test(j)) {
        for (int x : G.at(j)) {
          tmp.set(x);
        }
      }
    }
    Taka = tmp;
    bool fin = true;
    for (int j = 0; j < n; j++) {
      if (Taka.test(j)) {
        if (Aoki.test(j)) {
          Taka.reset(j);
        } else {
          fin = false;
        }
      }
    }
    if (fin) {
      cout << i << endl;
      break;
    }
    tmp.reset();
    for (int j = 0; j < n; j++) {
      if (Aoki.test(j)) {
        for (int x : G.at(j)) {
          tmp.set(x);
        }
      }
    }
    Aoki = tmp;
    fin = true;
    for (int j = 0; j < n; j++) {
      if (Taka.test(j)) {
        if (Aoki.test(j)) {
          Taka.reset(j);
        } else {
          fin = false;
        }
      }
    }
    if (fin) {
      cout << i + 1 << endl;
      break;
    }
  }
  return 0;
}
