N,u,v = map(int,input().split())
ls = []
for i in range(N-1):
  ls.append(list(map( int,input().split() )))
connected = [[] for i in range(N+1)]
for i in range(N-1):
  a,b = ls[i]
  connected[a].append(b)
  connected[b].append(a)
visited = [0 for i in range(N+1)]
q = [(v,0)]
near = 0
far = 0
while q:
  a,d = q.pop(0)
  visited[a] = 1
  for e in connected[a]:
    if not visited[e]:
      q.append((e,d+1))
  if a == u:
    distance = d
    break
q = [(u,0)]
visited = [0 for i in range(N+1)]
max_tail = 0
while q:
  a,d = q.pop(0)
  visited[a] = 1
  for e in connected[a]:
    if not visited[e] and e!=v:
      max_tail =max(max_tail,d+1)
      q.append((e,d+1))
cnt = 0
while distance>1:
  distance-= 1
  if max_tail>0:
    max_tail-=1
    distance +=1
  else:
    max_tail += 1
    distance -= 1
  cnt +=1
print(cnt)