N, u, v = map(int, input().split())
u, v = u-1, v-1
adjL = [set() for _ in range(N)]
for _ in range(N-1):
    A, B = map(int, input().split())
    A, B = A-1, B-1
    adjL[A].add(B)
    adjL[B].add(A)

ans = 0
v1s = set([u])
v2s = set([v])
useds = [False] * N
useds[v] = True
while True:
    vs = set()
    for v1 in v1s:
        vs |= adjL[v1]
    v1s = vs
    v1s -= v2s
    if not v1s: break

    ans += 1
    vs = set()
    for v2 in v2s:
        vs |= adjL[v2]
    v2s = set([v for v in vs if not useds[v]])
    for v2 in v2s:
        useds[v2] = True
    v1s -= v2s
    if not v1s: break

print(ans)
