from sys import setrecursionlimit

setrecursionlimit(1000000)

N, u, v = map(int, input().split())

node = [[] for _ in range(N)]
for _ in range(N - 1):
  A, B = [int(s) - 1 for s in input().split()]
  node[A].append(B)
  node[B].append(A)

def tak(node, u, v, p):
  #print('tak %d %d %d' % (u, v, p))
  if p > N:
    return float('inf')
  if u == v:
    return p
  return max(aok(node, n, v, p) for n in node[u])

def aok(node, u, v, p):
  #print('aok %d %d %d' % (u, v, p))
  if u == v:
    return p
  return min(tak(node, u, n, p + 1) for n in node[v])

print(tak(node, u - 1, v - 1, 0))