#include<stdio.h>
#include<iostream>
#include<vector>
#define M 50005
using namespace std;
struct Node{
int to,w;
};
vector<Node>G[M];
int dis[M];
void dfs(int x,int fa){
for(int i=0;i<G[x].size();i++){
int to=G[x][i].to;
if(to==fa)continue;
dfs(to,x);
dis[x]=max(dis[x],dis[to]+G[x][i].w);
}
}
int main(){
// freopen("tour.in","r",stdin);
// freopen("tour.out","w",stdout);
int n,sum=0;
scanf("%d",&n);
for(int i=1;i<n;i++){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
sum+=c;
G[a].push_back((Node){b,c});
G[b].push_back((Node){a,c});
}
dfs(1,-1);
printf("%d\n",sum*2-dis[1]);
return 0;
}