#include <bits/stdc++.h>
using namespace std;
int ni() {
  int a;
  scanf("%d", &a);
  return a;
}
double nf() {
  double a;
  scanf("%lf", &a);
  return a;
}
char sbuf[100005];
string ns() {
  scanf("%s", sbuf);
  return sbuf;
}
long long nll() {
  long long a;
  scanf("%lld", &a);
  return a;
}
template <class T>
void out(T a, T b) {
  bool first = true;
  for (T i = a; i != b; ++i) {
    if (!first) printf(" ");
    first = false;
    cout << *i;
  }
  printf("\n");
}
template <class T>
void outl(T a, T b) {
  for (T i = a; i != b; ++i) {
    cout << *i << "\n";
  }
}
int n, m;
const int maxn = 300005;
const int maxm = 600005;
int nx[maxm];
int to[maxm];
int fs[maxn];
long long cs[maxn];
int cnt;
long long ans, moo;
void adde(int a, int b, long long c) {
  nx[cnt] = fs[a];
  to[cnt] = b;
  cs[cnt] = c;
  fs[a] = cnt++;
}
void rec(int id, int f, long long acc) {
  moo = max(moo, acc);
  for (int i = fs[id]; i != -1; i = nx[i])
    if (to[i] != f) {
      rec(to[i], id, acc + cs[i]);
    }
}
int main() {
  int i, j, k;
  memset(fs, -1, sizeof(fs));
  n = ni();
  for (i = (0); i < (((n - 1))); ++i) {
    int a = ni();
    int b = ni();
    int c = ni();
    ans += (long long)c;
    adde(a - 1, b - 1, c);
    adde(b - 1, a - 1, c);
  }
  rec(0, -1, 0);
  printf("%lld\n", ans + ans - moo);
  return 0;
}
