import queue

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

path = [0]*n

ab = [[ ] for i in range(n)]

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

u -= 1
v -= 1

print(ab)

q = queue.Queue()

q.put(u)

while not q.empty():
    tmp = q.get()
    for i in range(len(ab[tmp])):
        if path[ab[tmp][i]] == 0:
            path[ab[tmp][i]] = path[tmp] + 1
            q.put(ab[tmp][i])

path2 = [0]*n

max_path = 0
pos = 0

for i in range(n):
    if max_path < path[i]:
        max_path = path[i]
        pos = i

q = queue.Queue()

q.put(v)
    
while not q.empty():
    tmp = q.get()
    for i in range(len(ab[tmp])):
        if path2[ab[tmp][i]] == 0:
            path2[ab[tmp][i]] = path2[tmp] + 1
            q.put(ab[tmp][i])


print(max_path-path2[pos])