n, u, v = map(int, input().split())
edges = [[] for i in range(n+1)]
for _ in range(n-1):
    ai, bi = map(int, input().split())
    edges[ai].append(bi)
    edges[bi].append(ai)

lst = [-1 for i in range(n+1)]
lst[v] = 0
kyori = 0
tugi = edges[v]
while True:
    kyori += 1
    tugitugi = []
    atta = 0
    for node in tugi:
        if lst[node] == -1:
            atta = 1
            lst[node] = kyori
            tugitugi.extend(edges[node])
    if atta == 0:
        print(kyori-2)
        exit()
    tugi = tugitugi[:]