from collections import deque
N,u,v = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N-1)]

def bfs(start,N,AB):
    d = [-1]*N
    d[start-1] = 0
    q = [start]
    cnt = 1
    while q:
        #print(d,q)
        q1 = []
        for i in q:
            for j in AB:
                if(j[0] == i and d[j[1]-1] == -1):
                    q1.append(j[1])
                    d[j[1]-1] = cnt
                if(j[1] == i and d[j[0]-1] == -1):
                    q1.append(j[0])
                    d[j[0]-1] = cnt
        q = q1
        cnt += 1
    return d
taka = bfs(u,N,AB)#takahashi
aoki = bfs(v,N,AB)
#print(taka,aoki)
fin = -1
for i in range(N):
    if(taka[i] < aoki[i]):
        fin = max(fin,aoki[i])
        ans = fin - (aoki[i]-taka[i]+1)//2
print(ans)