#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
inline int read(void){
int x=0,f=1; char ch=getchar();
for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
for(;ch>='0'&&ch<='9';x=(x<<3)+(x<<1)+ch-'0',ch=getchar());
return x*f;
}
const int maxn=50009;
struct LJM{
int to,w;
}; vector<LJM>f[maxn];
int dis[maxn];
void dfs(int x,int fa){
for(int i=0;i<f[x].size();i++){
int to=f[x][i].to;
if(to==fa) continue;
dfs(to,x);
dis[x]=max(dis[x],dis[to]+f[x][i].w);
}
}
int main(int argc,char const *argv[]){
int n=read(),sum=0;
for(int i=1;i<n;i++){
int a=read(),b=read(),c=read();
sum+=c;
f[a].push_back((LJM){b,c});
f[b].push_back((LJM){a,c});
}
dfs(1,-1);
cout<<sum*2-dis[1]<<endl;
return 0;
}