import numpy as np
n,u,v = map(int,input().split())
R = []
for _ in range(n):
    R.append([])
for _ in range(n-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    R[a].append(b)
    R[b].append(a)
taka = np.zeros(n)
taka[u]=1
aoki = np.zeros(n)
aoki[v]=1

def check(nige,oi):
    doko = nige.nonzero()
    flag = True
    for doko_i in doko[0]:
        if oi[doko_i]==0:
            flag = False
    return flag
    
    
t=1
while True:
    #taka
    #########
    next_taka = np.zeros(n)
    kiten = taka.nonzero()
    for kiten_i in kiten[0]:
        koho = R[kiten_i]
        for koho_i in koho:
            next_taka[koho_i]=1
    taka=next_taka
    #########
    if check(taka,aoki):
        break
        
    #aoki
    t+=1
    #########
    kiten = aoki.nonzero()
    for kiten_i in kiten[0]:
        koho = R[kiten_i]
        for koho_i in koho:
            aoki[koho_i]=1
    #########
    if check(taka,aoki):
        break
print(t)