import strutils, sequtils

const N_MAX = 100000

let
  input = stdin.readline.split.map(parseint)
  n = input[0]
  u = input[1]
  v = input[2]

var
  edges : array[1..N_MAX, array[1..N_MAX, bool]]

for i in 1..n-1:
  let input = stdin.readline.split.map(parseint)
  edges[input[0]][input[1]] = true
  edges[input[1]][input[0]] = true

# dfs

var
  takahashiDistance : array[1..N_MAX, int]
  aokiDistance : array[1..N_MAX, int]

proc dfs (arr : var array[1..N_MAX, int], start: int, step: int = 1)
proc dfs (arr : var array[1..N_MAX, int], start: int, step: int = 1) =
  arr[start] = step
  for i in 1..n:
    if edges[start][i] and arr[i] == 0:
      dfs(arr, i, step + 1)

dfs(takahashiDistance, u)
dfs(aokiDistance, v)

# search

var res : int
for i in 1..n:
  if aokiDistance[i] > max(takahashiDistance[i], res):
    res = aokiDistance[i]

echo res - 2
