def f_playing_tag_on_tree():
    N, U, V = [int(i) for i in input().split()]
    Edges = [[int(i) for i in input().split()] for j in range(N - 1)]

    tree = [[] for _ in range(N)]
    for u, v in Edges:
        tree[u - 1].append(v - 1)
        tree[v - 1].append(u - 1)

    depth = [-1] * N

    def dfs(current, parent, dep):
        depth[current] = dep

        for child in tree[current]:
            if child == parent:
                continue
            dfs(child, current, dep + 1)
        return None
    dfs(V - 1, -1, 0)
    return max(depth) - 1

print(f_playing_tag_on_tree())