#include <bits/stdc++.h>
using namespace std;
vector<int> e[100100];
int vu[100100], vv[100100];
void f(int x, int* v) {
  for (int i = 0; i < e[x].size(); i++) {
    if (v[e[x][i]] == 0) {
      v[e[x][i]] = v[x] + 1;
      f(e[x][i], v);
    }
  }
}
int main() {
  int N, u, v;
  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);
  }
  vu[u] = 1;
  f(u, vu);
  vv[v] = 1;
  f(v, vv);
  int max = 0;
  for (int i = 1; i <= N; i++) {
    if (vu[i] > vv[i] && max < vu[i]) max = vu[i];
  }
  printf("%d", max - 2);
  return 0;
}
