#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > g[100010];
long long ans;
void go(int cur, int par, long long tot) {
  if (g[cur].size() == 1 && par != -1) {
    ans = max(ans, tot);
    return;
  }
  for (auto next : g[cur]) {
    if (next.first != par) {
      go(next.first, cur, tot + next.second);
    }
  }
}
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 1; i < n; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    g[x].push_back({y, z});
    g[y].push_back({x, z});
    sum += z;
  }
  sum *= 2;
  go(1, -1, 0);
  sum = sum - ans;
  printf("%lld\n", sum);
  return 0;
}
