#include <bits/stdc++.h>
using namespace std;
int n, u, v;
vector<int> E[100010];
int dis[2][100010];
int main() {
  scanf("%d%d%d", &n, &u, &v);
  for (int i = 0; i < (n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    E[x].push_back(y);
    E[y].push_back(x);
  }
  for (int a = 0; a < (2); a++) {
    int st = (a ? v : u);
    vector<int> q;
    q.push_back(st);
    auto& D = dis[a];
    memset(D, -1, sizeof D);
    D[st] = 0;
    for (int i = 0; i < ((int)(q).size()); i++) {
      int t = q[i];
      for (int e : E[t])
        if (D[e] == -1) {
          D[e] = D[t] + 1;
          q.push_back(e);
        }
    }
  }
  int ans = 0;
  if (dis[0][v] % 2 == 0) ans = dis[0][v] / 2;
  for (int i = 1; i <= n; i++)
    if (dis[0][i] < dis[1][i]) ans = max(ans, dis[0][i]);
  printf("%d\n", ans);
  return 0;
}
