#include <bits/stdc++.h>
int make_rooted_tree(std::vector<std::vector<long long int> > &G,
                     long long int N, long long int root_index,
                     std::vector<std::vector<long long int> > &G_rooted,
                     std::vector<long long int> &par);
int sub_make_rooted_tree(std::vector<std::vector<long long int> > &G,
                         long long int N, long long int root_index,
                         std::vector<std::vector<long long int> > &G_rooted,
                         std::vector<long long int> &par);
int make_rooted_tree(std::vector<std::vector<long long int> > &G,
                     long long int N, long long int root_index,
                     std::vector<std::vector<long long int> > &G_rooted,
                     std::vector<long long int> &par) {
  par[root_index] = -1;
  sub_make_rooted_tree(G, N, root_index, G_rooted, par);
  return 0;
}
int sub_make_rooted_tree(std::vector<std::vector<long long int> > &G,
                         long long int N, long long int root_index,
                         std::vector<std::vector<long long int> > &G_rooted,
                         std::vector<long long int> &par) {
  for (long long int i = 0; i < G[root_index].size(); i++) {
    if (G[root_index][i] != par[root_index]) {
      par[G[root_index][i]] = root_index;
      G_rooted[root_index].push_back(G[root_index][i]);
      sub_make_rooted_tree(G, N, G[root_index][i], G_rooted, par);
    }
  }
  return 0;
}
long long int determine_rank(std::vector<std::vector<long long int> > &G_rooted,
                             long long int index) {
  if (G_rooted[index].size() == 0) {
    return 0;
  } else {
    long long int ans = 0;
    for (long long int i = 0; i < G_rooted[index].size(); i++) {
      ans = std::max(ans, determine_rank(G_rooted, G_rooted[index][i]) + 1);
    }
    return ans;
  }
}
int main() {
  long long int N, tmp1, tmp2, u, v;
  scanf("%lld%lld%lld", &N, &u, &v);
  std::vector<std::vector<long long int> > G(N);
  for (long long int i = 0; i < N - 1; i++) {
    scanf("%lld%lld", &tmp1, &tmp2);
    G[tmp1 - 1].push_back(tmp2 - 1);
    G[tmp2 - 1].push_back(tmp1 - 1);
  }
  std::cerr << N << " " << u << " " << v << std::endl;
  std::vector<std::vector<long long int> > G_rooted(N);
  std::vector<long long int> par(N);
  par[v - 1] = -1;
  make_rooted_tree(G, N, v - 1, G_rooted, par);
  long long int dist_uv = 0;
  tmp1 = u - 1;
  while (tmp1 != v - 1) {
    dist_uv++;
    tmp1 = par[tmp1];
  }
  std::cerr << "Answer: " << std::endl;
  if (dist_uv == 1 && determine_rank(G_rooted, u - 1) == 0) {
    std::cout << 0 << std::endl;
  } else if ((dist_uv + 2) % 2 == 0) {
    std::cout << dist_uv + determine_rank(G_rooted, u - 1) - 1 << std::endl;
  } else {
    std::cout << dist_uv + determine_rank(G_rooted, u - 1) << std::endl;
  }
  return 0;
}
