#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > adjlist[110];
bool visited[110];
int dfs(int id) {
  int ret = 0, nxt, cost;
  visited[id] = true;
  for (int j = 0; j < (int)adjlist[id].size(); j++) {
    nxt = adjlist[id][j].first;
    cost = adjlist[id][j].second;
    if (visited[nxt]) continue;
    ret = max(ret, dfs(nxt) + cost);
  }
  return ret;
}
int main() {
  int n, u, v, w, maxi;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d %d %d", &u, &v, &w);
    adjlist[u].push_back(make_pair(v, w));
    adjlist[v].push_back(make_pair(u, w));
  }
  memset(visited, false, sizeof visited);
  maxi = dfs(0);
  printf("%d\n", maxi);
  return 0;
}
