from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

n,u,v=map(int,input().split())

row,col,w=[],[],[]
for i in range(n-1):
 a,b=map(int,input().split())
 row.append(a-1)
 col.append(b-1)
 w.append(1)

g=csr_matrix((w,(row,col)),shape=(n,n))

d_u=dijkstra(g,directed=False,indices=u-1)
d_v=dijkstra(g,directed=False,indices=v-1)

l=0
for t_u,t_v in zip(d_u,d_v):
 if t_u<t_v:
  l=max(l,t_v)
print(int(l)-1)