n,u,v=map(int,input().split())
edge=[[] for i in range(n+1)]
for i in range(n-1):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
ans=0
a=set([v])
t=set([u])
j=1
while t:
    if j:
        tl=t
        j^=1
        t=set()
        for i in tl:
            t|=set(edge[i])
        t-=a
    else:
        tl=a
        j^=1
        a=set()
        for i in tl:
            a|=set(edge[i])
        t-=a
        ans+=1
print(ans)