let () = Scanf.scanf "%d %d %d\n" @@ fun n u v ->
  let es = Array.make n [] in
  for i = 0 to n - 2 do
    Scanf.scanf "%d %d\n" @@ fun a b ->
      es.(a - 1) <- b - 1 :: es.(a - 1);
      es.(b - 1) <- a - 1 :: es.(b - 1)
  done;
  let rec visit visited depth d u =
    if not visited.(u) then begin
      depth.(u) <- d;
      visited.(u) <- true;
      List.iter (visit visited depth (d + 1)) es.(u)
    end in
  let depthT = Array.make n 0 in
  let depthA = Array.make n 0 in
  visit (Array.make n false) depthT 0 (u - 1);
  visit (Array.make n false) depthA 0 (v - 1);
  Printf.printf "%d\n" @@
  if List.for_all (( = ) (v - 1)) es.(u - 1) then 0 else
  Array.fold_left max min_int @@
  Array.init n @@ fun i ->
    if depthA.(i) <= depthT.(i)
    then min_int
    else depthT.(i) - (depthT.(i) - depthA.(i) + 1) mod 2
