import javafx.util.Pair;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
static ArrayList<ArrayList<Pair<Integer,Integer>>> tree;
static int total;
static boolean[] kayty;
static int n;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
n = input.nextInt();
tree = new ArrayList<>(n+1);
for (int i = 0; i < n+1; i++) {
tree.add(new ArrayList<>());
}
kayty = new boolean[n+1];
for (int i = 0; i < n-1; i++) {
int a = Integer.parseInt(input.next());
int b = Integer.parseInt(input.next());
int x = Integer.parseInt(input.next());
ArrayList<Pair<Integer,Integer>> neighbors = tree.get(a);
ArrayList<Pair<Integer,Integer>> neighbors2 = tree.get(b);
neighbors.add(new Pair<>(b,x));
neighbors2.add(new Pair<>(a,x));
}
for (int i = 0; i < tree.size(); i++) {
kayty = new boolean[n+1];
kayty[i] = true;
count(i,Integer.MAX_VALUE);
}
System.out.println(total/2);
}
private static void count(int index, int min) {
ArrayList<Pair<Integer,Integer>> naapurit = tree.get(index);
kayty[index] = true;
for (Pair<Integer, Integer> naapuri : naapurit) {
if (!kayty[naapuri.getKey()]) {
int val = Math.min(min,naapuri.getValue());
total += val;
count(naapuri.getKey(),val);
}
}
}
}