#include <bits/stdc++.h>
std::vector<std::vector<long long> > to(100000 + 5);
long long N;
long long length[100000 + 5];
void dfs(long long start, long long parent = -1) {
  for (long long i = 0; i < to[start].size(); i++) {
    if (to[start][i] == parent) {
      continue;
    }
    length[to[start][i]] = length[start] + 1;
    dfs(to[start][i], start);
  }
  return;
}
long long calculate_dist(long long start, long long dest) {
  for (long long i = 0; i < N; i++) {
    length[i] = -1;
  }
  length[start] = 0;
  dfs(start);
  return length[dest];
}
int main() {
  scanf("%lld", &N);
  long long takahashi, aoki;
  scanf("%lld", &takahashi);
  scanf("%lld", &aoki);
  takahashi--;
  aoki--;
  long long temp1, temp2;
  for (long long i = 0; i < N - 1; i++) {
    scanf("%lld", &temp1);
    scanf("%lld", &temp2);
    temp1--;
    temp2--;
    to[temp2].push_back(temp1);
    to[temp1].push_back(temp2);
  }
  long long ans = 0;
  for (long long i = 0; i < N; i++) {
    if (calculate_dist(aoki, i) > calculate_dist(takahashi, i)) {
      long long temp = calculate_dist(aoki, i);
      ans = fmax(ans, temp);
    }
  }
  ans--;
  printf("%lld\n", ans);
  return 0;
}
