
from collections import deque
N, u, v = map(int, input().split())
u, v = u-1, v-1
AB = [list(map(int, input().split())) for a in range(N-1)]

G = [[] for a in range(N)]

for ab in AB:
  G[ab[0]-1].append(ab[1]-1)
  G[ab[1]-1].append(ab[0]-1)
#print(AB)
#print(G)

def bfs(current, goal):
#  print('bfs start')
#  print(current, goal)
  q = deque([current])
  costs = [0 for a in range(N)]
  done = [0 for a in range(N)]
  done[current] = 1
  while q:
    start = q.popleft()
#    print(start)
    if start == goal:
      return costs[goal]
    for i in G[start]:
      if done[i] == 0:
        q.append(i)
        costs[i] = costs[start] + 1
        done[i] = 1

distances = [0]
for i in range(N):
#  print(i)
  aoki = bfs(i, v)
  takahashi = bfs(i, u)
  if aoki > takahashi:
    distances.append(aoki)

print(max(distances)-1)