output_description: Print the number of moves Aoki will perform before the end of the game.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N u v
      A_1 B_1
      :
      A_{N-1} B_{N-1}
attempt: import sys
  
  readline = sys.stdin.readline
  
  # 青木君からの到達距離 - 高橋君からの到達距離が最も大きい場所に逃げるべき
  # そこに到達したときに、
  # 高橋君と青木君の距離が偶数のとき
  # 青 - x - x - x - 高
  # 青 - x - x - 高 - x
  # x - 青 - x - 高 - x
  # x - 青 - x - x - 高
  # x - x - 青 - x - 高
  # x - x - 青- 高 - x
  # x - x - x - 終 - x
  # 青木君からの距離 - 1が答え
  # 高橋君と青木君の距離が奇数のとき
  # 青 - x - x - 高
  # 青 - x - 高 - x
  # x - 青 - 高 - x
  # x - 青 - x - 高
  # x - x - 青 - 高
  # x - x - 終 - x
  # やっぱり青木君からの距離 - 1が答え
  # つまり、
  # ・[青木君からの距離が遠い場所について]
  # ・[青木君からの距離 - 1]が答え
  
  N, u, v = map(int, readline().split())
  G = [[] for i in range(N)]
  for i in range(N - 1):
      a, b = map(int, readline().split())
      G[a - 1].append(b - 1)
      G[b - 1].append(a - 1)
  
  dist_from_u = [0 for i in range(N)]  # 高橋君からの距離
  dist_from_v = [0 for i in range(N)]  # 青木君からの距離
  
  stack = []
  # 頂点, 高橋君からの距離, 親
  stack.append([u - 1, 0, -1])
  while stack:
      e, dist, parent = stack.pop()
      dist_from_u[e] = dist
      for child in G[e]:
          if child == parent:
              continue
          stack.append([child, dist + 1, e])
  
  stack = []
  # 頂点, 青木君からの距離, 親
  stack.append([v - 1, 0, -1])
  while stack:
      e, dist, parent = stack.pop()
      dist_from_v[e] = dist
      for child in G[e]:
          if child == parent:
              continue
          stack.append([child, dist + 1, e])
  
  maxdiff_from_v = 0
  for i in range(N):
      if dist_from_u[i] < dist_from_v[i]:
          if maxdiff_from_v < dist_from_v[i]:
              maxdiff_from_v = dist_from_v[i]
  
  print(maxdiff_from_v - 1)
  
problem_description: Statement
  
  We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i
  bidirectionally.
  
  Takahashi is standing at Vertex u, and Aoki is standing at Vertex v.
  
  Now, they will play a game of tag as follows:
  
    * 1. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Takahashi moves to a vertex of his choice that is adjacent to his current vertex.
  
    * 2. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Aoki moves to a vertex of his choice that is adjacent to his current vertex.
  
    * 3. Go back to step 1.
  
  Takahashi performs his moves so that the game ends as late as possible, while
  Aoki performs his moves so that the game ends as early as possible.
  
  Find the number of moves Aoki will perform before the end of the game if both
  Takahashi and Aoki know each other's position and strategy.
  
  It can be proved that the game is bound to end.
samples: [{"input": "5 4 1\n    1 2\n    2 3\n    3 4\n    3 5", "output": "2\n    \n\nIf both players play optimally, the game will progress as follows:\n\n  * Takahashi moves to Vertex 3.\n  * Aoki moves to Vertex 2.\n  * Takahashi moves to Vertex 5.\n  * Aoki moves to Vertex 3.\n  * Takahashi moves to Vertex 3.\n\nHere, Aoki performs two moves.\n\nNote that, in each move, it is prohibited to stay at the current vertex.\n\n* * *"}, {"input": "5 4 5\n    1 2\n    1 3\n    1 4\n    1 5", "output": "1\n    \n\n* * *"}, {"input": "2 1 2\n    1 2", "output": "0\n    \n\n* * *"}, {"input": "9 6 1\n    1 2\n    2 3\n    3 4\n    4 5\n    5 6\n    4 7\n    7 8\n    8 9", "output": "5"}]