#include <bits/stdc++.h>
using namespace std;
int N, u, v, c;
vector<pair<int, int> > figli[100];
bool visited[100];
int sol;
void visit(int nodo, int cost) {
  visited[nodo] = 1;
  for (pair<int, int> f : figli[nodo])
    if (!visited[f.first]) visit(f.first, cost + f.second);
  sol = max(sol, cost);
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> u >> v >> c;
    figli[u].push_back(pair<int, int>(v, c));
    figli[v].push_back(pair<int, int>(u, c));
  }
  visit(0, 0);
  cout << sol;
  return 0;
}
