#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
vector<vector<int>> T;
int visit[100010] = {};
int dist_u[100010] = {};
int dist_v[100010] = {};
int max_dist_v[100010];
void calc_dist(int n, int now, int d[]) {
  visit[n] = 1;
  d[n] = now;
  for (int next : T[n]) {
    if (visit[next]) continue;
    calc_dist(next, now + 1, d);
  }
}
int calc_max_dist_v(int n) {
  visit[n] = 1;
  max_dist_v[n] = dist_v[n];
  for (int next : T[n]) {
    if (visit[next]) continue;
    max_dist_v[n] = max(max_dist_v[n], calc_max_dist_v(next));
  }
  return max_dist_v[n];
}
int main(void) {
  int n, u, v;
  scanf("%d %d %d", &n, &u, &v);
  --u;
  --v;
  T = vector<vector<int>>(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a;
    --b;
    T[a].push_back(b);
    T[b].push_back(a);
  }
  fill(visit, visit + 100010, 0);
  calc_dist(u, 0, dist_u);
  fill(visit, visit + 100010, 0);
  calc_dist(v, 0, dist_v);
  fill(visit, visit + 100010, 0);
  calc_max_dist_v(v);
  int res = 0;
  for (int i = 0; i < n; ++i) {
    if (dist_u[i] >= dist_v[i]) {
      continue;
    }
    int cost = max_dist_v[i];
    if ((dist_v[i] - dist_u[i]) % 2 == 1) {
      cost--;
    }
    res = max(res, cost);
  }
  cout << res << endl;
  return 0;
}
