#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l, w;
  cin >> n >> l >> w;
  l--;
  w--;
  vector<vector<bool>> list(n, vector<bool>(n, false));
  for (int i = 0; i < n - 1; i++) {
    int n1, n2;
    cin >> n1 >> n2;
    list.at(n1 - 1).at(n2 - 1) = true;
    list.at(n2 - 1).at(n1 - 1) = true;
  }
  vector<int> numw(n, 1e9);
  vector<int> numl(n, 1e9);
  queue<int> q;
  q.push(w);
  numw.at(w) = 0;
  while (q.size()) {
    int temp = q.front();
    q.pop();
    for (int i = 0; i < n; i++) {
      if (list.at(temp).at(i) && numw.at(i) == 1e9) {
        numw.at(i) = numw.at(temp) + 1;
        q.push(i);
      }
    }
  }
  q.push(l);
  numl.at(l) = 0;
  while (q.size()) {
    int temp = q.front();
    q.pop();
    for (int i = 0; i < n; i++) {
      if (list.at(temp).at(i) && numl.at(i) == 1e9) {
        numl.at(i) = numl.at(temp) + 1;
        q.push(i);
      }
    }
  }
  int end = 0;
  for (int i = 0; i < n; i++) {
    if (numw.at(i) > numl.at(i)) {
      end = max(end, numw.at(i));
    }
  }
  cout << end - 1 << endl;
}
