#include <bits/stdc++.h>
using namespace std;
long long MOD = 998244353;
const long long N = 1e6 + 5;
vector<pair<long long, long long>> adj[N];
long long ans = 0;
long long dfs(long long n, long long p) {
  long long mx = 0;
  for (auto x : adj[n]) {
    if (x.first != p) {
      mx = max(x.second + dfs(x.first, n), mx);
    }
  }
  return mx;
}
void peace() {
  long long n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    adj[a].push_back({b, c});
    adj[b].push_back({a, c});
    ans += 2 * c;
  }
  ans -= dfs(1, -1);
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  t = 1;
  while (t--) peace();
}
