n, u, v = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n - 1)]

# n, u, v = 9, 6, 1
# ab = [[1,2],[2,3],[3,4],[4,5],[5,6],[4,7],[7,8],[8,9]]

from collections import defaultdict
graph = defaultdict(list)
for i in range(n - 1):
    a = ab[i][0] - 1
    b = ab[i][1] - 1
    graph[a].append(b)
    graph[b].append(a)
u -= 1
v -= 1

visited = [0] * n
def dfs(cur, target, path):
    # print(cur, path)
    visited[cur] = 1
    if cur == target:
        return path
    else:
        for v in graph[cur]:
            if not visited[v]:
                p = dfs(v, target, path + [v])
                if p:
                    return p

path = dfs(v, u, [v])
print(len(path))