import sys
sys.setrecursionlimit(2 * 10 ** 5)

n, u, v = map(int, input().split())
conn = {}
for _ in range(n-1):
    ai, bi = map(int, input().split())
    if conn.get(ai):
        conn.get(ai).add(bi)
    else:
        conn[ai] = {bi}
        
    if conn.get(bi):
        conn.get(bi).add(ai)
    else:
        conn[bi] = {ai}
    
def hoge(start, geta, dist_dict):
    dist_dict[start] = geta
    for i in conn[start]:
        if dist_dict.get(i) == None:
            hoge(i, geta + 1, dist_dict)

    
u_dist = {} # 子
hoge(u, 0, u_dist)
v_dist = {} # 鬼
hoge(v, 0, v_dist)

if (u_dist[1] - v_dist[1]) % 2: # 子の手番で捕まる
    print(max([val for k, val in u_dist.items() if val < v_dist[k]]))
else: # 鬼の手番で捕まる
    print(1 + max([val for k, val in u_dist.items() if val < v_dist[k]]))

