N, u, v = map(int, input().split())
edge = [set() for i in range(N)]

for i in range(N-1):
  a, b = map(int, input().split())
  edge[a-1].add(b-1)
  edge[b-1].add(a-1)

depth = [-1] * N
stack = [(v-1, 0)]

while stack:
  cur, curD = stack.pop()
  depth[cur] = curD
  for c in edge[cur]:
    if depth[c] != -1: continue
    stack.append((c, curD+1))

print(max(depth)-1)