def dijkstra(s, n, w, cost):
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0

    while True:
        v = -1
        for i in range(n):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True

        for j in range(n):
            d[j] = min(d[j], d[v]+cost[v][j])
    return d


n, u, v = map(int, input().split())
u -= 1
v -= 1
cost = [[float("inf") for i in range(n)] for i in range(n)]

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    cost[a][b] = 1
    cost[b][a] = 1
d = dijkstra(v, n, n-1, cost)
ans = d[u]

print(ans-1)
