import sys
sys.setrecursionlimit(10**7)

def dfs(v,d):
  ret=d
  checked[v]=1
  for u in g[v]:
    if checked[u]==1:
      continue
    ret=max(ret,dfs(u,d+1))
  return ret  

n,u,v=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
checked=[0]*(n+1)
ans=dfs(v,0)-1
print(ans)