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: n = input()
  m = n.split()
  p = [int(i) for i in m]
  from collections import deque
  
  list = []
  for i in range(p[0] - 1):  # 因数注意！
      n = input()
      m = n.split()
      q = [int(i) for i in m]  # 1列の数列をリスト化
      list.append(q)
  l = [[] for i in range(p[0] + 1)]
  for pi in list:  # 0-originedに注意
      l[pi[0]].append(pi[1])
      l[pi[1]].append(pi[0])
  sousa = deque([[p[2], 0, 0]])  # [捜査対象ノード,親ノード,そのノードの距離]
  node = [
      [] for i in range(p[0])
  ]  # n番目のリストにn+1について[親ノード,rootからの距離,子ノード]
  while len(sousa) != 0:
      a = sousa.popleft()
      b = l[a[0]]
      if a[1] != 0:
          b.remove(a[1])
      if len(b) == 0:
          pass
      else:
          for i in b:
              sousa.append([i, a[0], a[2] + 1])
      node[a[0] - 1] = [a[1]] + [a[2]] + b
  dis = node[p[1] - 1][1]
  takahashi = p[1]
  max = dis
  hate = p[1]
  for i in range((dis + 1) // 2):
      tansaku = deque([[takahashi, dis]])
      if i >= 1:
          kitatoko = takahashi
          takahashi = node[takahashi - 1][0]
          a = tansaku.popleft()
          b = node[takahashi - 1][2:]
          b.remove(kitatoko)
          if len(b) == 0:
              continue
          else:
              for j in b:
                  tansaku.append([j, dis + 1 - i])
  
      while len(tansaku) != 0:
          a = tansaku.popleft()
          b = node[a[0] - 1][2:]
          print()
          if len(b) == 0:
              pass
          else:
              for j in b:
                  tansaku.append([j, a[1] + 1])
  
      if max < a[1]:
          max = a[1]
          hate = a[0]
  print(node[hate - 1][1] - 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"}]