import sys
sys.setrecursionlimit(10**6)

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

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

def dfs(x, p, d, dep):
    dep[x] = d
    for i in G[x]:
        if i==p:
            pass
        else:
            dfs(i,x,d+1, dep)
    return dep

du = [0]*N
dv = [0]*N
du = dfs(u,-1,0, du)
dv = dfs(v,-1,0, dv)

ans = 0


def dfs2(x, p, d):
    global ans
    for i in G[x]:
        if i==p:
            pass
        elif  du[i]<dv[i]:
            dfs2(i,x, d+1)
        elif du[i]==dv[i]:
            ans = max(ans, d+1)
    ans = max(ans, d)

dfs2(u,-1,0)
print(ans)
