import sys
sys.setrecursionlimit(100010)

n,u,v = [int(i)-1 for i in input().split()]
n+=1
AB = [[int(i)-1 for i in input().split()] for _ in range(n-1)]

nodes = [[] for _ in range(n)]
for ab in AB:
    nodes[ab[1]].append(ab[0])
    nodes[ab[0]].append(ab[1])

route = []
def search(p,before=-1):
    if len(nodes[p])==1 and p!=u:
        return False
    for node in nodes[p]:
        if node == before:
            continue
        if search(node,p) or node==v:
            route.append(p)
            return True
    return False
search(u)
route.reverse()
key = route[(len(route)-1)//2]
if len(route) == 1:
    nodes[key].remove(v)
else:
    nodes[key].remove(route[(len(route)-1)//2+1])

que = [key]
time = -1
while len(que)>0:
    time+=1
    newque = []
    while len(que)>0:
        p = que.pop()
        for q in nodes[p]:
            nodes[q].remove(p)
            newque.append(q)
    que=newque
time = max(0,time)

print( (len(route)-1)//2+time )