#include <bits/stdc++.h>
using namespace std;
vector<int> edge[100000];
void dfs(int index, int *dist) {
  for (int i = 0; i < edge[index].size(); i++) {
    if (-1 == dist[edge[index][i]]) {
      dist[edge[index][i]] = dist[index] + 1;
      dfs(edge[index][i], dist);
    }
  }
  return;
}
void solv() {
  int N, u, v;
  scanf("%d%d%d", &N, &u, &v);
  for (int i = 0; i < N - 1; i++) {
    int A, B;
    scanf("%d%d", &A, &B);
    A--;
    B--;
    edge[A].push_back(B);
    edge[B].push_back(A);
  }
  int distT[100000];
  fill(distT, distT + N, -1);
  distT[u - 1] = 0;
  dfs(u - 1, distT);
  int distA[100000];
  fill(distA, distA + N, -1);
  distA[v - 1] = 0;
  dfs(v - 1, distA);
  int enc = distT[v - 1] / 2;
  int distT2[100000];
  fill(distT2, distT2 + N, -1);
  for (int i = 0; i < N; i++) {
    if (distA[i] <= enc) {
      distT2[i] = -2;
    }
  }
  distT2[u - 1] = 0;
  dfs(u - 1, distT2);
  int d = 0, index;
  for (int i = 0; i < N; i++) {
    if (distT2[i] > d) {
      d = distT2[i];
      index = i;
    }
  }
  if (0 == d) {
    if (1 == distA[u - 1]) {
      printf("0");
    } else {
      printf("1");
    }
  } else {
    printf("%d", distA[index] - 1);
  }
  return;
}
int main() {
  FILE *fin = NULL, *fout = NULL;
  solv();
  if (NULL != fin) fclose(fin);
  if (NULL != fout) fclose(fout);
  return 0;
}
