def find_most_deep(s):
  global nodes
  check=nodes[s][2][:]
  rt=0
  if len(check)==0:
    return 0
  for i in range(len(check)):
    rt=max(rt,1+find_most_deep(check[i]))
  return rt

Nuv=input().split(" ")
N=int(Nuv[0])
u=int(Nuv[1])-1
v=int(Nuv[2])-1
edge=[]
for i in range(N-1):
  ab=input().split(" ")
  a=int(ab[0])-1
  b=int(ab[1])-1
  edge+=[[min(a,b),max(a,b)]]
edge.sort()
#print(N)
#print(u)
#print(v)
#print(edge)

nodes=[0]*N #[深さ,1つ浅いノード,[1つ深いノード]]
for i in range(N):
  nodes[i]=[-1,-1,-1]
  nodes[i][2]=[]

nodes[v]=[0,-1,[]]
next_depth=[v]
new_next_depth=[]

while len(next_depth)>0:
  for j in range(len(next_depth)):
    i=0
    while i<len(edge):
      if edge[i][0]==next_depth[j]:
        nodes[next_depth[j]][2]+=[edge[i][1]]
        nodes[edge[i][1]][0]=nodes[next_depth[j]][0]+1
        nodes[edge[i][1]][1]=next_depth[j]
        new_next_depth+=[edge[i][1]]
        edge.pop(i)
      elif edge[i][1]==next_depth[j]:
        nodes[next_depth[j]][2]+=[edge[i][0]]
        nodes[edge[i][0]][0]=nodes[next_depth[j]][0]+1
        nodes[edge[i][0]][1]=next_depth[j]
        new_next_depth+=[edge[i][0]]
        edge.pop(i)
      else:
        i+=1
  next_depth=new_next_depth[:]
  new_next_depth=[]
  
#print(nodes)
#[深さ,1つ浅いノード,[1つ深いノード]]
ans=0
ans+=(nodes[u][0]-1)//2
is_odd=nodes[u][0]%2
#print(ans)
for i in range(ans):
  u=nodes[u][1]
#print(u)
#find most deep
#print(find_most_deep(u))
if is_odd:
  print(ans+find_most_deep(u))
else:
  print(ans+find_most_deep(u)+1)