from collections import defaultdict


def find_path(adj, to_node, node, parent=None):
    if node == to_node:
        return [to_node]
    path = None
    for child in adj[node]:
        if child == parent:
            continue
        p = find_path(adj, to_node, child, node)
        if p is None:
            continue
        p = [node] + p
        if path is None or len(path) > len(p):
            path = p
    return path


def depth(adj, node, parent=None):
    ret = 0
    for child in adj[node]:
        if child == parent:
            continue
        d = depth(adj, child, node) + 1
        ret = max(ret, d)
    return ret


def main():
    N, U, V = list(map(int, input().split(' ')))
    U -= 1
    V -= 1
    adj = defaultdict(list)
    for _ in range(N - 1):
        A, B = list(map(lambda x: int(x) - 1, input().split(' ')))
        adj[A].append(B)
        adj[B].append(A)
    path = find_path(adj, U, V)  # to U from V
    dist = len(path) - 1
    partial_depth = depth(adj, path[(dist // 2) + 1], path[dist // 2])
    print(partial_depth + (dist // 2))


if __name__ == '__main__':
    main()
