N,U,V=map(int,input().split())
if U==V:
    print(0)
    exit()

G=[[]*N for _ in range(N)]
for i in range(N-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)


from collections import deque
que=deque()
que.append([V-1,0])
#print(que)
visited=[0]*(N+1)
visited[V-1]=1
fin=[]
while que:
    vcnt=que.pop()
    #print(vcnt)
    v=vcnt[0]
    cnt=vcnt[1]
    if v==U:
        cnt_U=cnt
    #print(v,cnt)
    flg=True
    for u in G[v]:
        if visited[u]==0:
            que.appendleft([u,cnt+1])
            visited[u]=1
            flg=False

    if flg:
        fin.append([v,cnt])
fin.sort(key=lambda x:x[1])

print(fin[-1][1]-1)
