# include < iostream >
# include < cstring >
# include <queue >
# include <vector >
const int maxn =100020;
using namespace std;
int dis[ maxn ],ans;
bool vis[ maxn ];
vector <pair <int ,int > > V[ maxn ];
int bfs(int x){
memset (dis ,0, sizeof (dis ));
memset (vis ,0, sizeof (vis ));
queue <int >Q;
Q. push (x); vis[x]=1;
int point =0;
while (!Q. empty ()){
int F=Q. front ();
Q.pop ();
if( dis[F]> ans ){
ans =dis [F];
point =F;
}
pair <int ,int >t;
for (int i=0;i<V[F]. size ();i ++){
t=V[F][i];
if(vis [t. first ]==0){
vis [t. first ]=1;
dis [t. first ]= dis[F]+t. second ;
Q. push (t. first );
}
}
}
return point ;
}
int main (){
int x,y,z;
while (cin >>x>>y>>z){
V[x]. push_back ( make_pair (y,z));
V[y]. push_back ( make_pair (x,z));
}
ans =0;
int point =bfs (1);
ans =0;
bfs( point );
cout <<ans << endl ;
return 0;
}