#include <bits/stdc++.h>
int main(void) {
  int n, u, v;
  std::cin >> n >> u >> v;
  u--;
  v--;
  std::vector<std::unordered_set<int> > adjacent(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    std::cin >> a >> b;
    a--;
    b--;
    adjacent[a].insert(b);
    adjacent[b].insert(a);
  }
  std::vector<int> distance_from_u(n, -1);
  std::stack<int> st;
  distance_from_u[u] = 0;
  st.push(u);
  while (!st.empty()) {
    int now = st.top();
    st.pop();
    for (const auto& elem : adjacent[now]) {
      if (distance_from_u[elem] == -1) {
        distance_from_u[elem] = distance_from_u[now] + 1;
        st.push(elem);
      }
    }
  }
  std::vector<int> distance_from_v(n, -1);
  distance_from_v[v] = 0;
  st.push(v);
  while (!st.empty()) {
    int now = st.top();
    st.pop();
    for (const auto& elem : adjacent[now]) {
      if (distance_from_v[elem] == -1) {
        distance_from_v[elem] = distance_from_v[now] + 1;
        st.push(elem);
      }
    }
  }
  int best = 0;
  for (int i = 0; i < n; i++) {
    if (distance_from_u[i] > distance_from_v[i]) continue;
    if (distance_from_u[i] - distance_from_v[i] % 2) distance_from_v[i] -= 1;
    if (best < distance_from_v[i]) best = distance_from_v[i];
  }
  std::cout << best << std::endl;
  return 0;
}
