output_description: Print the minimum number of vertices that you need to remove in order to
  produce a good tree.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N K
      A_1 B_1
      A_2 B_2
      :
      A_{N-1} B_{N-1}
attempt: n, k = map(int, input().split())
  tree = [[] for i in range(n)]
  for _ in range(n - 1):
      a, b = sorted(map(int, input().split()))
      tree[a - 1].append(b - 1)
      tree[b - 1].append(a - 1)
  
  
  def search(tree, pos, past=None, depth=0):
      """
      子孫ノードを探索して、最深のノードとその深さを返す
      """
      # 子ノードを探索する
      ress = []  # 子ノードの探索結果
      for next_node in tree[pos]:
          # next_nodeが親なら探索しない
          if next_node == past:
              continue
          res = search(tree, next_node, pos, depth + 1)
          ress.append(res)
  
      ress.sort(reverse=True)
  
      # 子ノードがいないならばこのノードとその深さを返す
      if len(ress) == 0:
          ress = [[depth, pos]]
  
      return ress[0]
  
  
  def countChildren(tree, pos):
      """
      ノードposを根ノードとした場合の
      深さ毎のノードを数える
      """
  
      def dfs(tree, pos, child_list=[], past=None, depth=0):
          child_list += [0] * (depth + 1 - len(child_list))
  
          child_list[depth] += 1
  
          # 子ノードを探索する
          for next_node in tree[pos]:
              # next_nodeが親なら探索しない
              if next_node == past:
                  continue
              dfs(tree, next_node, child_list, pos, depth + 1)
  
      child_list = []
      dfs(tree, pos, child_list)
      return child_list[:]
  
  
  # 最遠頂点対 u,vと直径diameterを求める
  _, u = search(tree, 0)
  diameter, v = search(tree, u)
  
  # u,vを頂点ノードとしたときの深さ毎のノードを数える
  u_list = countChildren(tree, u)
  v_list = countChildren(tree, v)
  
  removed_nodes = 0
  
  while diameter > k:
      if u_list[-1] < v_list[-1]:
          removed_nodes += u_list[-1]
          u_list.pop()
      else:
          removed_nodes += v_list[-1]
          v_list.pop()
      diameter -= 1
  
  print(removed_nodes)
  
problem_description: Statement
  
  Given an undirected tree, let the distance between vertices u and v be the
  number of edges on the simple path from u to v. The diameter of a tree is the
  maximum among the distances between any two vertices. We will call a tree
  _good_ if and only if its diameter is at most K.
  
  You are given an undirected tree with N vertices numbered 1 through N. For
  each i (1≦i≦N-1), there is an edge connecting vertices A_i and B_i.
  
  You want to remove zero or more vertices from the tree, so that the resulting
  tree is good. When a vertex is removed, all incident edges will also be
  removed. The resulting graph must be connected.
  
  Find the minimum number of vertices that you need to remove in order to
  produce a good tree.
samples: [{"input": "6 2\n    1 2\n    3 2\n    4 2\n    1 6\n    5 6", "output": "2\n    \n\nThe tree is shown below. Removing vertices 5 and 6 will result in a good tree\nwith the diameter of 2.\n\n![ctree.png](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/ctree.png)\n\n* * *"}, {"input": "6 5\n    1 2\n    3 2\n    4 2\n    1 6\n    5 6", "output": "0\n    \n\nSince the given tree is already good, you do not need to remove any vertex."}]