#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  vector<vector<int>> edge(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  set<int> evil;
  evil.insert(v);
  set<int> human;
  human.insert(u);
  int time = 0;
  while (true) {
    set<int> nhuman;
    for (const int& s : human) {
      for (const int& x : edge[s]) {
        if (evil.find(x) == evil.end()) nhuman.insert(x);
      }
    }
    human = nhuman;
    if (human.empty()) {
      break;
    }
    set<int> nevil;
    time++;
    for (const int& s : evil) {
      for (const int& x : edge[s]) {
        nevil.insert(x);
      }
    }
    evil = nevil;
    for (const int& s : evil) {
      human.erase(s);
    }
    if (human.empty()) break;
  }
  cout << time << endl;
}
