#include <bits/stdc++.h>
using namespace std;
void f() { return; }
void g() {}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  vector<int> ta(n, 1001001001);
  vector<int> ao(n, 1001001001);
  ta[u] = 0;
  ao[v] = 0;
  vector<vector<int>> tr(n);
  for (int i = 0; i < (int)(n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    tr[a].push_back(b);
    tr[b].push_back(a);
  }
  {
    queue<int> q;
    q.push(u);
    while (!q.empty()) {
      int now = q.front();
      q.pop();
      for (auto c : tr[now]) {
        if (ta[c] > ta[now] + 1) {
          ta[c] = ta[now] + 1;
          q.push(c);
        }
      }
    }
  }
  {
    queue<int> q;
    q.push(v);
    while (!q.empty()) {
      int now = q.front();
      q.pop();
      for (auto c : tr[now]) {
        if (ao[c] > ao[now] + 1) {
          ao[c] = ao[now] + 1;
          q.push(c);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (ta[i] < ao[i]) {
      ans = max(ans, max(0, ta[i] + (ao[i] - ta[i]) / 2));
    }
  }
  cout << ans << endl;
  return 0;
}
