#include <bits/stdc++.h>
using namespace std;
int vis[100005];
vector<long long> city[100005];
vector<long long> cost[100005];
int n;
long long ans = 0;
long long max(long long a, long long b) {
  if (a >= b) return a;
  return b;
}
long long dfs(int x, int p) {
  long long ans = 0;
  for (int i = 0; i < city[x].size(); i++) {
    if (city[x][i] != p) {
      ans = max(ans, cost[x][i] + dfs(city[x][i], x));
    }
  }
  return ans;
}
int main() {
  cin >> n;
  long long s = 0;
  int c1, c2, tim1;
  for (int i = 0; i < n - 1; i++) {
    cin >> c1 >> c2 >> tim1;
    city[c1].push_back(c2);
    city[c2].push_back(c1);
    cost[c1].push_back(tim1);
    cost[c2].push_back(tim1);
    s += tim1;
  }
  s = 2 * s;
  long long g = dfs(1, 0);
  g = s - g;
  cout << g << endl;
  return 0;
}
