#include <bits/stdc++.h>
using namespace std;
struct vertex {
  int par;
  vector<int> to;
};
int n, u, v;
vertex ver[100000];
int d[2][100000];
void dfs(int x, bool y) {
  for (auto &i : ver[x].to) {
    if (i == ver[x].par) continue;
    ver[i].par = x;
    d[y][i] = d[y][x] + 1;
    dfs(i, y);
  }
}
int main() {
  scanf("%d %d %d", &n, &u, &v);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    ver[a - 1].to.push_back(b - 1);
    ver[b - 1].to.push_back(a - 1);
  }
  ver[u - 1].par = u - 1;
  dfs(u - 1, 0);
  ver[v - 1].par = v - 1;
  dfs(v - 1, 1);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (d[1][i] <= d[0][i]) continue;
    ans = max(ans, d[0][i] + (d[1][i] - d[0][i]) / 2);
  }
  printf("%d\n", ans);
  return 0;
}
