#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
long long expo(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2 == 0) {
    long long ret = expo(a, b / 2);
    ret = (ret * ret) % 1000000007;
    return ret;
  } else {
    long long ret = expo(a, b / 2);
    ret = (ret * ret) % 1000000007;
    ret = (ret * a) % 1000000007;
    return ret;
  }
}
bool is_prime(long long x) {
  if (x == 1) return false;
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
int arr[200005], sze[200005];
int root(int i) {
  while (arr[i] != i) i = arr[arr[i]];
  return i;
}
void unionn(int u, int v) {
  int a = root(u);
  int b = root(v);
  if (a == b) return;
  if (sze[a] > sze[b]) swap(a, b);
  arr[a] = arr[b];
  sze[b] += sze[a];
}
long long inf = 1e18;
long long n;
vector<long long> v[100005];
map<pair<long long, long long>, long long> mp;
long long ans;
void dfs(int x, int p, long long t) {
  if (x != 1 && v[x].size() == 1) {
    ans = max(ans, t);
    return;
  }
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i] != p) {
      dfs(v[x][i], x, t + mp[{x, v[x][i]}]);
    }
  }
}
int main() {
  scanf("%lld", &n);
  long long m = n - 1, x, y, w, tot = 0;
  while (m--) {
    scanf("%lld%lld%lld", &x, &y, &w);
    v[x].push_back(y);
    v[y].push_back(x);
    mp[{x, y}] = w;
    mp[{y, x}] = w;
    tot += w;
  }
  dfs(1, 0, 0);
  long long fans = 2 * tot - ans;
  printf("%I64d", fans);
}
