#include <bits/stdc++.h>
std::vector<int> depth_u;
std::vector<int> depth_v;
int cnt = 0;
void dfs(const std::vector<std::vector<int> >& Graph, int v, int p, int d,
         std::vector<int>& depth) {
  depth[v] = d;
  for (auto next_v : Graph[v]) {
    if (next_v == p) {
      continue;
    }
    dfs(Graph, next_v, v, d + 1, depth);
  }
}
int main() {
  int N, u, v, a, b, cnt;
  std::cin >> N >> u >> v;
  std::vector<std::vector<int> > Graph;
  Graph.resize(N + 1);
  for (int i = 0; i < N - 1; i++) {
    std::cin >> a >> b;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }
  int cn = 0;
  depth_u.resize(N + 1);
  depth_v.resize(N + 1);
  dfs(Graph, u, -1, 0, depth_u);
  dfs(Graph, v, -1, 0, depth_v);
  std::vector<int> array;
  for (int i = 0; i < N + 2; i++) {
    if (depth_v[i] > depth_u[i]) {
      array.push_back(depth_v[i]);
    }
  }
  std::cout << *std::max_element(array.begin(), array.end()) - 1 << std::endl;
  return 0;
}
