N,u,v=map(int,input().split())
dist_v=[-1 for _ in range(N+1)]
dist_u=[-1 for _ in range(N+1)]
Graph=[[] for _ in range(N+1) for _ in range(N+1)]

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

def dfs(v,dist=0):
    dist_v[v]=dist
    for nv in Graph[v]:
        if dist_v[nv]!=-1:
            continue
        dfs(nv,dist+1)  

def dfs_u(u,dist=0):
    dist_u[u]=dist
    for nu in Graph[u]:
        if dist_u[nu]!=-1:
            continue
        if dist+1>=dist_v[nu]:
            continue
        dfs_u(nu,dist+1)
dfs(v)
dfs_u(u)
print(dist_v[dist_u.index(max(dist_u))]-1)