N,u,v = map(int, input().split())
edge = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    

dicT = {u-1:0}
dicA = {v-1:0}
ans = 0
while len(dicT) > 0 and len(dicA) > 0:
    tempT = {}
    for t in dicT:
        for e in edge[t]:
            if e not in dicA:
                tempT[e] = 0
                
    dicT = tempT
    if not dicT:
        break
    tempA = {}
    for a in dicA:
        for e in edge[a]:
            if e in dicT:
                dicT[e] = 1
            else:
                tempA[e] = 0
    
    dicA = tempA
    
    tempT = {}
    for t in dicT:
        if dicT[t] == 0:
            tempT[t] = 0
            
    dicT = tempT
    ans += 1
    
print(ans)