from collections import deque

N, u, v = map(int, input().split())
Tree = [[] for _ in range(N)]

for _ in range(N-1):
  A, B = map(lambda x:int(x)-1, input().split())
  Tree[A].append(B)
  Tree[B].append(A)

def bfs(start):
  INF = 10 ** 9
  dist = [INF] * N
  dist[start] = 0
  q = deque([start])
  while q:
    v = q.popleft()
    dv = dist[v]
    for w in Tree[v]:
      dw = dv + 1
      if dw >= dist[w]:
        continue
      dist[w] = dw
      q.append(w)
  return dist

dist = bfs(v-1)
des = max(dist)

print(des-1)