output_description: Print the minimum k such that the given tree is a tree of uninity k.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N
      a_1 b_1
      :
      a_{N-1} b_{N-1}
attempt: #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  
  
  def calc(rt):
      e = edge[rt]
      f[rt] = 1
      g[rt] = 1
      g1 = 0
      g2 = 0
      for son in e:
          if f[son] == 0:
              calc(son)
              res = f[son]
              if res > f[rt]:
                  f[rt] = res
              res = g[son]
              if res + 1 > g[rt]:
                  g[rt] = res + 1
              if res > g1:
                  g2 = g1
                  g1 = res
              elif res > g2:
                  g2 = res
      if g1 + g2 + 1 > f[rt]:
          f[rt] = g1 + g2 + 1
      if g[rt] > f[rt]:
          f[rt] = g[rt]
  
  
  n = int(input())
  edge = []
  f = []
  g = []
  for i in range(0, n):
      edge.append(set())
      f.append(0)
      g.append(0)
  
  for i in range(1, n):
      e = input().split(" ")
      y = int(e[0]) - 1
      x = int(e[1]) - 1
      edge[x].add(y)
      edge[y].add(x)
  
  calc(0)
  
  length = f[0]
  ans = 0
  l = 1
  while l < length:
      ans = ans + 1
      l = l + l + 1
  print(ans)
  
problem_description: Statement
  
  We will recursively define _uninity_ of a tree, as follows: (_Uni_ is a
  Japanese word for sea urchins.)
  
    * A tree consisting of one vertex is a tree of uninity 0.
    * Suppose there are zero or more trees of uninity k, and a vertex v. If a vertex is selected from each tree of uninity k and connected to v with an edge, the resulting tree is a tree of uninity k+1.
  
  It can be shown that a tree of uninity k is also a tree of uninity
  k+1,k+2,..., and so forth.
  
  You are given a tree consisting of N vertices. The vertices of the tree are
  numbered 1 through N, and the i-th of the N-1 edges connects vertices a_i and
  b_i.
  
  Find the minimum k such that the given tree is a tree of uninity k.
samples: [{"input": "7\n    1 2\n    2 3\n    2 4\n    4 6\n    6 7\n    7 5", "output": "2\n    \n\nA tree of uninity 1 consisting of vertices 1, 2, 3 and 4 can be constructed\nfrom the following: a tree of uninity 0 consisting of vertex 1, a tree of\nuninity 0 consisting of vertex 3, a tree of uninity 0 consisting of vertex 4,\nand vertex 2.\n\nA tree of uninity 1 consisting of vertices 5 and 7 can be constructed from the\nfollowing: a tree of uninity 1 consisting of vertex 5, and vertex 7.\n\nA tree of uninity 2 consisting of vertices 1, 2, 3, 4, 5, 6 and 7 can be\nconstructed from the following: a tree of uninity 1 consisting of vertex 1, 2,\n3 and 4, a tree of uninity 1 consisting of vertex 5 and 7, and vertex 6.\n\n* * *"}, {"input": "12\n    1 2\n    2 3\n    2 4\n    4 5\n    5 6\n    6 7\n    7 8\n    5 9\n    9 10\n    10 11\n    11 12", "output": "3"}]