#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  vector<vector<int>> con(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    con.at(a).push_back(b);
    con.at(b).push_back(a);
  }
  vector<int> vec(n, -1);
  vec.at(v) = 0;
  queue<int> q;
  q.push(v);
  while (q.size() > 0) {
    int p = q.front();
    q.pop();
    for (int c : con.at(p)) {
      if (vec.at(c) >= 0) continue;
      vec.at(c) = vec.at(p) + 1;
      q.push(c);
    }
  }
  int s = 1;
  while (true) {
    int next = -1;
    for (int p : con.at(u)) {
      if (next < 0 && vec.at(p) < vec.at(u))
        next = p;
      else if (vec.at(p) < vec.at(next))
        next = p;
    }
    if (vec.at(next) > s)
      u = next;
    else
      break;
  }
  int m = vec.at(u);
  for (int i = 0; i < n; i++) {
    vec.at(i) -= m;
  }
  sort(vec.rbegin(), vec.rend());
  cout << m + vec.at(0) - 1 << endl;
}
