N, u, v = map(int, input().split())
u -= 1
v -= 1
tree = [[] for _ in range(N)]
inf = 10 ** 5 + 1

for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    tree[a].append(b)
    tree[b].append(a)

amemo = [inf] * N
tmemo = [inf] * N
def dfs_a(i, c):
    if amemo[i] != inf:
        return
    amemo[i] = c
    for j in tree[i]:
        dfs_a(j, c+1)
def dfs_t(i, c):
    if tmemo[i] != inf:
        return
    tmemo[i] = c
    for j in tree[i]:
        dfs_t(j, c+1)
dfs_a(v, 0)
dfs_t(u, 0)
ans = 0
for t, a in zip(tmemo, amemo):
    if t < a:
        ans = max(ans, a)

print(ans-1)
