n, u, v = map(int, input().split())
u, v = u - 1, v - 1
nodes = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    nodes[a].append(b)
    nodes[b].append(a)


def search(parent, node, depth):
    chokudai_depth = 0
    max_depth = depth
    if node == u:
        chokudai_depth = depth
    if len(nodes[node]) == 1 and parent != -1:
        return max_depth, chokudai_depth
    for child in nodes[node]:
        if child != parent:
            _max_depth, _chokudai_depth = search(node, child, depth + 1)
            max_depth = max(max_depth, _max_depth)
            chokudai_depth = max(chokudai_depth, _chokudai_depth)
    return max_depth, chokudai_depth


max_depth, chokudai_depth = search(-1, v, 0)
print(max_depth - chokudai_depth + ((chokudai_depth) // 2) + 1 + (chokudai_depth % 2))
