import sys

sys.setrecursionlimit(10**6)

N, u, v = list(map(int, input().split()))

g = [[] for i in range(N)]

for i in range(N-1):
    a,b = list(map(int, input().split()))
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    
seen_u = [0] * N
seen_v = [0] * N
dict_u = [0] * N
dict_v = [0] * N

seen_u[u-1] = 1
seen_v[v-1] = 1

def dfs(G, cr, seen, dct):
    for i in G[cr]:
        if seen[i] == 0:
            seen[i] = 1
            dct[i] = dct[cr] + 1
            dfs(G, i, seen, dct)

dfs(g, u-1, seen_u, dict_u)
dfs(g, v-1, seen_v, dict_v)


print(max([uv-vv for uv,vv in zip(dict_u, dict_v)])-1)