N,u,v=[int(i) for i in input().split(" ")]
u-=1
v-=1
graph=[[0 for i in range(N)] for j in range(N)]
for i in range(N-1):
    A,B=[int(j) for j in input().split(" ")]
    graph[A-1][B-1]=1
    graph[B-1][A-1]=1

dist_takahashi=[-1 for i in range(N)]
dist_takahashi[u]=0
next=[u]
d=1
while -1 in dist_takahashi:
    _next=[]
    for n in next:
        for i in range(N):
            if graph[n][i]==1 and dist_takahashi[i]==-1:
                _next.append(i)
    for n in _next:
        dist_takahashi[n]=d
    next=_next
    d+=1

dist_aoki=[-1 for i in range(N)]
dist_aoki[v]=0
next=[v]
d=1
while -1 in dist_aoki:
    _next=[]
    for n in next:
        for i in range(N):
            if graph[n][i]==1 and dist_aoki[i]==-1:
                _next.append(i)
    for n in _next:
        dist_aoki[n]=d
    next=_next
    d+=1


retval=0

for i in range(N):
    if dist_aoki[i]<dist_takahashi[i]:
        continue

    retval=max(retval,dist_aoki[i]-1)


print(retval)
