import sys
sys.setrecursionlimit(10**9)

N, u, v=map(int, input().split())
path=[[] for i in range(N+1)]
for i in range(N-1):
  a, b=map(int, input().split())
  path[a].append(b)
  path[b].append(a)
  
def f(past, x, y, path):
  past.append(x)
  if x==y:
    return past
  else:
    n=len(path[x])
    if len(past)>1 and n==1:
      return past
    else:
      for i in range(n):
        if len(past)==1 or path[x][i]!=past[-2]:
          past=f(past, path[x][i], y, path)
      return past
  
shortpath=f([], v, u, path)
print(shortpath)
print(path)
path[u].remove(shortpath[-2])

def g(path, y, x, c):
  c+=1
  n=len(path[x])
  for i in range(n):
    if path[x][i]!=y:
      c=g(path, x, path[x][i], c)
  return c

k=len(path[u])
cand=0
for i in range(k):
  cand=max(cand, g(path, u, path[u][i], 0))
  
print(len(shortpath)-2+cand//2)