import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n,u,v=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n-1)]

dic=[[] for i in range(n+1)]
for i in range(n-1):
    a,b=ab[i]
    dic[a].append(b)
    dic[b].append(a)
itta=[0]*(n+1)
ta=deque([u])
ao=deque([v])
itta[v]=1
cnt=0
while 1:
    for i in range(len(ta)):
        tmp=ta.popleft()
        if itta[tmp]==1:
            continue
        for i in dic[tmp]:
            if itta[i]==0:
                ta.append(i)
    if len(ta)==0:
        print(cnt)
        break
    cnt+=1
    for i in range(len(ao)):
        tmp=ao.popleft()
        for i in dic[tmp]:
            if itta[i]==0:
                itta[i]=1
                ao.append(i)
    # print(ta)
    # print(ao)