#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  int father;
  vector<int> sons;
  int d;
} nodes[1000];
vector<pair<int, int>> cango[1000];
int maxa;
void dfs(int nowpos, int nowfather) {
  for (auto au : cango[nowpos]) {
    if (au.first == nowfather) continue;
    nodes[au.first].father = nowpos;
    nodes[nowpos].sons.push_back(au.first);
    nodes[au.first].d = nodes[nowpos].d + au.second;
    maxa = max(maxa, nodes[au.first].d);
    dfs(au.first, nowpos);
  }
}
int main() {
  scanf("%d", &n);
  int l, r, c;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &l);
    scanf("%d", &r);
    scanf("%d", &c);
    cango[l].push_back({r, c});
    cango[r].push_back({l, c});
  }
  maxa = 0;
  dfs(0, -1);
  printf("%d\n", maxa);
  return 0;
}
