




'''simple docstring'''



import sys
from collections import defaultdict






class 							_a				:





       '''simple docstring'''






       def __init__(      self  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						[]







       def        UpperCamelCase_							(      self,							A  ):







             '''simple docstring'''







             return self.node_position[vertex]







       def        UpperCamelCase_							(      self,							A,							A  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      str    					=						pos







       def        UpperCamelCase_							(      self,							A,							A,							A,							A  ):







             '''simple docstring'''







             if start > size // 2 - 1:
                   return
             else:
                   if 2 * start + 2 >= size:
                         SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						2 * start + 1
                   else:
                         if heap[2 * start + 1] < heap[2 * start + 2]:
                               SCREAMING_SNAKE_CASE   :      str    					=						2 * start + 1
                         else:
                               SCREAMING_SNAKE_CASE   :      Optional[int]    					=						2 * start + 2
                   if heap[smallest_child] < heap[start]:
                         SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE   :      List[str]    					=						heap[smallest_child], positions[smallest_child]
                         SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE   :      Tuple    					=						(
                             heap[start],
                             positions[start],
                         )
                         SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE   :      List[str]    					=						temp, tempa

                         SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						self.get_position(positions[smallest_child]  )
                         self.set_position(
                             positions[smallest_child],							self.get_position(positions[start]  )  )
                         self.set_position(positions[start],							A  )

                         self.top_to_bottom(A,							A,							A,							A  )







       def        UpperCamelCase_							(      self,							A,							A,							A,							A  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      Tuple    					=						position[index]

             while index != 0:
                   SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						int((index - 2) / 2  ) if index % 2 == 0 else int((index - 1) / 2  )

                   if val < heap[parent]:
                         SCREAMING_SNAKE_CASE   :      List[Any]    					=						heap[parent]
                         SCREAMING_SNAKE_CASE   :      List[str]    					=						position[parent]
                         self.set_position(position[parent],							A  )
                   else:
                         SCREAMING_SNAKE_CASE   :      Optional[int]    					=						val
                         SCREAMING_SNAKE_CASE   :      List[Any]    					=						temp
                         self.set_position(A,							A  )
                         break
                   SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						parent
             else:
                   SCREAMING_SNAKE_CASE   :      Optional[int]    					=						val
                   SCREAMING_SNAKE_CASE   :      Any    					=						temp
                   self.set_position(A,							0  )







       def        UpperCamelCase_							(      self,							A,							A  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      int    					=						len(A  ) // 2 - 1
             for i in range(A,							-1,							-1  ):
                   self.top_to_bottom(A,							A,							len(A  ),							A  )







       def        UpperCamelCase_							(      self,							A,							A  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						positions[0]
             SCREAMING_SNAKE_CASE   :      Any    					=						sys.maxsize
             self.top_to_bottom(A,							0,							len(A  ),							A  )
             return temp




def   lowercase__(			__UpperCamelCase:					Any    ):

      """simple docstring"""






      SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						Heap()

      SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						[0] * len(__UpperCamelCase    )
      SCREAMING_SNAKE_CASE   :      Tuple    					=						[-1] * len(__UpperCamelCase    )  # Neighboring Tree Vertex of selected vertex
      # Minimum Distance of explored vertex with neighboring vertex of partial tree
      # formed in graph
      SCREAMING_SNAKE_CASE   :      str    					=						[]  # Heap of Distance of vertices from their neighboring vertex
      SCREAMING_SNAKE_CASE   :      Tuple    					=						[]

      for vertex in range(len(__UpperCamelCase    )    ):
            distance_tv.append(sys.maxsize    )
            positions.append(__UpperCamelCase    )
            heap.node_position.append(__UpperCamelCase    )

      SCREAMING_SNAKE_CASE   :      List[Any]    					=						[]
      SCREAMING_SNAKE_CASE   :      int    					=						1
      SCREAMING_SNAKE_CASE   :      Union[str, Any]    					=						sys.maxsize
      for neighbor, distance in adjacency_list[0]:
            SCREAMING_SNAKE_CASE   :      Any    					=						0
            SCREAMING_SNAKE_CASE   :      Optional[int]    					=						distance
      heap.heapify(__UpperCamelCase      ,__UpperCamelCase    )

      for _ in range(1      ,len(__UpperCamelCase    )    ):
            SCREAMING_SNAKE_CASE   :      List[Any]    					=						heap.delete_minimum(__UpperCamelCase      ,__UpperCamelCase    )
            if visited[vertex] == 0:
                  tree_edges.append((nbr_tv[vertex], vertex)    )
                  SCREAMING_SNAKE_CASE   :      Optional[int]    					=						1
                  for neighbor, distance in adjacency_list[vertex]:
                        if (
                            visited[neighbor] == 0
                            and distance < distance_tv[heap.get_position(__UpperCamelCase    )]
                        ):
                              SCREAMING_SNAKE_CASE   :      Optional[int]    					=						distance
                              heap.bottom_to_top(
                                  __UpperCamelCase      ,heap.get_position(__UpperCamelCase    )      ,__UpperCamelCase      ,__UpperCamelCase    )
                              SCREAMING_SNAKE_CASE   :      Dict    					=						vertex
      return tree_edges


if __name__ == "__main__":  # pragma: no cover
      # < --------- Prims Algorithm --------- >
      UpperCamelCase_    	=				int(input("Enter number of edges: ").strip())
      UpperCamelCase_    	=				defaultdict(list)
      for _ in range(edges_number):
            UpperCamelCase_    	=				[int(x) for x in input().strip().split()]
            adjacency_list[edge[0]].append([edge[1], edge[2]])
            adjacency_list[edge[1]].append([edge[0], edge[2]])
      print(prisms_algorithm(adjacency_list))








'''simple docstring'''



def   lowercase__(			__UpperCamelCase:					int = 1_00_00_00    ):

      """simple docstring"""






      SCREAMING_SNAKE_CASE   :      Tuple    					=						[i - 1 for i in range(limit + 1    )]

      for i in range(2      ,limit + 1    ):
            if phi[i] == i - 1:
                  for j in range(2 * i      ,limit + 1      ,__UpperCamelCase    ):
                        phi[j] -= phi[j] // i

      return sum(phi[2 : limit + 1]    )


if __name__ == "__main__":
      print(solution())


