import sys
si = sys.stdin.readline


def BFS(g, s, e):
    d = 1
    q = [s]
    visited = set()
    visited.add(s)
    if s == e:
        return 0

    while (len(q) != 0):
        qs = len(q)
        for _ in range(qs):
            qpop = q[0]
            q = q[1:]
            for v in g[qpop]:
                if v == e:
                    return d
                if v not in visited:
                    q.append(v)
                    visited.add(v)
        d += 1

    return d


def main():
    l = [int(e) for e in si().split()]
    n, u, v, ans, graph = l[0], l[1], l[2], 0, {}

    for _ in range(n-1):
        l = [int(e) for e in si().split()]
        if l[0] not in graph:
            graph[l[0]] = set()
        if l[1] not in graph:
            graph[l[1]] = set()
        graph[l[0]].add(l[1])
        graph[l[1]].add(l[0])

    while 1:
        T_options = {}
        for node in graph[u]:
            T_options[node] = BFS(graph, node, v)

        maxValue = max(T_options.values())
        print('T_options:')
        print(T_options)

        for (key, value) in T_options.items():
            if value == maxValue:
                u = key
                print('T is now at:')
                print(u)
                break

        if u == v:
            print(ans)
            break

        ans += 1
        A_options = {}
        for node in graph[v]:
            A_options[node] = BFS(graph, node, u)

        minValue = min(A_options.values())
        print('A_options:')
        print(A_options)

        for (key, value) in A_options.items():
            if value == minValue:
                v = key
                print('A is now at:')
                print(v)
                break

        if u == v:
            print(ans)
            break


if __name__ == '__main__':
    main()
