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

def hoge(start, geta, dist_dict):
    dist_dict[start] = geta
    for i, e in enumerate(g[start]):
      if e == 1 and dist_dict.get(i) == None:
        hoge(i, geta + 1, dist_dict)

    
u_dist = {}
hoge(u - 1, 0, u_dist)
v_dist = {}
hoge(v - 1, 0, v_dist)

print(max([v for k, v in u_dist.items() if v < v_dist[k]]) + (0 if v_dist[u - 1] % 2 else 1))
