import sys
sys.setrecursionlimit(10**5)

# input
n, u, v = map(int, list(input().split()))

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

print(tree)

# process
def f(line, maxlen):
    print(line)
    edges = tree[line[-1]]
    if len(line) == 1 or len(edges) > 1:
        for e in edges :
            if len(line) ==1 or not e == line[-2]:
                l = line[:]
                l.append(e)
                maxlen = f(l, maxlen)
        return maxlen

    else:
        if len(line) > maxlen: maxlen = len(line)
        return maxlen

# output
print(f([v-1], 0)-2)
