N, u, v = map(int, input().split())
graph = [[] for _ in range(N+1)]
 
for _ in range(N-1):
  a, b = map(int, input().split())
  graph[a].append(b)
  graph[b].append(a)

def Dfs(x):
  X = [-1] * (N + 1)
  stack = [x]
  X[x] = 0
  while stack:
    s = stack.pop()
    for g in graph[s]:
      if X[g] == -1:
        X[g] = X[s] + 1
        stack.append(g)
  return X

T = Dfs(u)
A = Dfs(v)
print("T:", T)
print("A:", A)

answer = []
for i in range(1, N + 1):
  if A[i] > T[i]:
    if len(graph[i]) == 0 and A[i] - T[i] == 1:
      answer.append(T[i])
    else:
      answer.append(T[i] + (A[i] - T[i]) // 2)
print(max(answer))