#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > arr[111];
int vis[111], maxs;
void dfs(int now, int wei) {
  if (vis[now]) return;
  vis[now] = 1;
  maxs = max(maxs, wei);
  for (int e = 0; e < arr[now].size(); e++) {
    int next = arr[now][e].first, n_wei = wei + arr[now][e].second;
    if (vis[next]) continue;
    dfs(next, n_wei);
  }
}
int main(void) {
  int n;
  cin >> n;
  for (int e = 0; e < n - 1; e++) {
    int a, b, c;
    cin >> a >> b >> c;
    arr[a].push_back(make_pair(b, c));
    arr[b].push_back(make_pair(a, c));
  }
  dfs(0, 0);
  cout << maxs;
}
