#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v[101];
int arr[101];
int dfs(int i) {
  arr[i] = 1;
  int c = 0;
  for (int j = 0; j < v[i].size(); j++) {
    if (arr[v[i][j].first] == 0) {
      int k = dfs(v[i][j].first) + v[i][j].second;
      if (k > c) c = k;
    }
  }
  return c;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, x, c;
    cin >> u >> x >> c;
    v[u].push_back(make_pair(x, c));
    v[x].push_back(make_pair(u, c));
  }
  cout << dfs(0);
}
