import sys, numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson  
from collections import defaultdict
from itertools import product, permutations, combinations

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

N, u, v = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N-1)]

adjm = [[float('inf')] * N for _ in range(N)]
for ab in AB:
    a, b = ab[0]-1, ab[1]-1
    adjm[a][b] = 1
    adjm[b][a] = 1
    
dv = dijkstra(adjm, indices=v-1)
du = dijkstra(adjm, indices=u-1)
dOK = [(i>j)*i for i, j in zip(dv, du)]

print(int(max(dOK)-1))