#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, l, u, v, t, arr[100009], brr[100009], vis[100009],
    vis1[100009], ans;
vector<int> vv[100009];
void bfs(int node) {
  queue<int> q;
  arr[node] = 0;
  q.push(node);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    vis[x] = 1;
    for (int ii = 0; ii < vv[x].size(); ii++) {
      int y = vv[x][ii];
      if (vis[y]) continue;
      q.push(y);
      arr[y] = arr[x] + 1;
    }
  }
  return;
}
void bfs1(int node) {
  queue<int> q;
  brr[node] = 0;
  q.push(node);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    vis1[x] = 1;
    for (int ii = 0; ii < vv[x].size(); ii++) {
      int y = vv[x][ii];
      if (vis1[y]) continue;
      q.push(y);
      brr[y] = brr[x] + 1;
      if (brr[y] <= arr[y]) {
        int xxx = arr[y] - brr[y];
        ans = max(ans, arr[y] - 1);
      }
    }
  }
  return;
}
int main() {
  scanf("%d %d %d", &n, &u, &v);
  for (i = 1; i < n; i++) {
    scanf("%d %d", &k, &l);
    vv[k].push_back(l);
    vv[l].push_back(k);
  }
  bfs(v);
  bfs1(u);
  printf("%d\n", ans);
}
