#%%
import numpy as np
n,nige,oni = map(int,input().split())
aa = np.zeros((n,n),dtype=bool)
for i in range(n-1):
    a,b = map(int,input().split())
    aa[a-1][b-1] = 1
    aa[b-1][a-1] = 1
nigel = np.zeros(n,dtype=bool)
nigel[nige-1] = 1
onil = np.zeros(n,dtype=bool)
onil[oni-1] = 1
ans = 0
for i in range(n-1):
    nigel = np.any(aa[nigel] == True,axis = 0)
    if np.logical_and(onil,nigel).sum() == nigel.sum():
        print(ans)
        exit()
    ans += 1
    onil = np.any(aa[onil] == True,axis = 0)
    nigel = np.logical_and(nigel,~onil)
    if nigel.sum() == 0:
        print(ans)
        exit()