N,u,v = map(int,input().split())
inf = 10**9
d = [[inf for i in range(N+1)] for j in range(N+1)]
G = [[] for i in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
    d[a][b] = 1
    d[b][a] = 1
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(1,n+1):
        for i in range(1,n+1):
            for j in range(1,n+1):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
warshall_floyd(d)
ans = 0
while u != v:
    m = 0
    for i in G[u]:
        if d[u][i] > m:
            m = d[u][i]
            a = i
    u = a
    if u != v:
        m = inf
        for j in G[v]:
            if d[v][j] < m:
                m = d[v][j]
                b = j
        v = b
        ans += 1
print(ans)