#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcd(long long a, long long b) {
  if (b == 0) return a;
  return (a / gcd(a, b)) * b;
}
vector<int> calc(long long num) {
  int dig;
  vector<int> p;
  while (num) {
    dig = num % 10;
    p.push_back(dig);
    num /= 10;
  }
  return p;
}
int N, U, V;
vector<int> G[10000];
int d[2][100000];
void dijk(long long s, int x) {
  fill(d[x], d[x] + N, (1e9));
  d[x][s] = 0;
  priority_queue<pair<int, int> > que;
  que.push(pair<int, int>(0, s));
  while (!que.empty()) {
    int u = que.top().second, cost = que.top().first;
    que.pop();
    if (d[x][u] < cost) continue;
    for (int v : G[u]) {
      if (d[x][v] > cost + 1) {
        d[x][v] = cost + 1;
        que.push(pair<int, int>(cost + 1, v));
      }
    }
  }
}
int main() {
  cin >> N >> U >> V;
  U--;
  V--;
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dijk(V, 0);
  dijk(U, 1);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (d[0][i] > d[1][i]) {
      if ((d[0][i] - d[1][i]) % 2 == 1) {
        ans = max(ans, d[0][i] - 1);
      } else
        ans = max(ans, d[0][i]);
    }
  }
  cout << ans << endl;
}
