output_description: Print the maximum total number of ingredients that Snuke's N servings of
  Skewer Meal can hold.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N
      L_1 L_2 ... L_{2N}
attempt: from collections import deque
  
  N, K = map(int, input().split())
  T = [[] for i in range(N)]
  E = []
  for i in range(N - 1):
      a, b = map(int, input().split())
      a, b = a - 1, b - 1
      T[a].append(b)
      T[b].append(a)
      E.append((a, b))
  
  
  def bfs(n):
      visited = [False] * N
      dist = [0] * N
      queue = deque([n])
      while queue:
          node = queue.pop()
          if visited[node]:
              continue
          visited[node] = True
          for n in T[node]:
              if not visited[n]:
                  dist[n] = dist[node] + 1
                  queue.appendleft(n)
      return dist
  
  
  dist = []
  for i in range(N):
      dist.append(bfs(i))
  
  ans = float("inf")
  if K % 2 == 0:
      # 全ての頂点について全探索
      for i in range(N):
          ans = min(ans, len([d for d in dist[i] if d > K / 2]))
  else:
      # 全ての辺について全探索
      for a, b in E:
          adist = [
              (1 if min(d1, d2) > (K - 1) / 2 else 0) for d1, d2 in zip(dist[a], dist[b])
          ]
          ans = min(ans, sum(adist))
  
  print(ans)
  
problem_description: Statement
  
  Snuke is having a barbeque party.
  
  At the party, he will make N servings of _Skewer Meal_.
  
  ![](https://agc001.contest.atcoder.jp/img/agc/001/Gg9pvPKw/abbq.png)
  
  Example of a serving of Skewer Meal
  
  He has a stock of 2N skewers, all of which will be used in Skewer Meal. The
  length of the i-th skewer is L_i. Also, he has an infinite supply of
  ingredients.
  
  To make a serving of Skewer Meal, he picks 2 skewers and threads ingredients
  onto those skewers. Let the length of the shorter skewer be x, then the
  serving can hold the maximum of x ingredients.
  
  What is the maximum total number of ingredients that his N servings of Skewer
  Meal can hold, if he uses the skewers optimally?
samples: [{"input": "2\n    1 3 1 2", "output": "3\n    \n\nIf he makes a serving using the first and third skewers, and another using the\nsecond and fourth skewers, each serving will hold 1 and 2 ingredients, for the\ntotal of 3.\n\n* * *"}, {"input": "5\n    100 1 2 3 14 15 58 58 58 29", "output": "135"}]