#include <bits/stdc++.h>
using namespace std;
int n, x, y;
vector<int> G[100000];
int P[100000];
int Q[100000];
void rec(int* a, int from, int prev, int dist) {
  a[from] = dist;
  for (int to : G[from]) {
    if (to == prev) continue;
    rec(a, to, from, dist + 1);
  }
}
int main() {
  cin >> n >> x >> y;
  --x;
  --y;
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rec(P, x, -1, 0);
  rec(Q, y, -1, 0);
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    if (P[i] >= Q[i]) continue;
    mx = max(mx, (P[i] + Q[i]) / 2);
  }
  cout << mx << endl;
}
