#include <bits/stdc++.h>
using namespace std;
int n, a[101][101], w[101][101], vis[101];
int root_leaf_dfs(int i, int wt) {
  int mx = 0;
  vis[i] = 1;
  for (int j = 0; j < n; j++) {
    if (a[i][j] == 1 && !vis[j]) {
      mx = max(root_leaf_dfs(j, wt + w[i][j]), mx);
    }
  }
  return mx ? mx : wt;
}
int main() {
  int u, v, c;
  cin >> n;
  for (int i = 0; i < 101; i++) {
    vis[i] = 0;
    for (int j = 0; j < 101; j++) {
      a[i][j] = 0;
      w[i][j] = 0;
    }
  }
  for (int i = 1; i < n; i++) {
    cin >> u >> v >> c;
    a[u][v] = 1;
    a[v][u] = 1;
    w[u][v] = c;
    w[v][u] = c;
  }
  cout << root_leaf_dfs(0, 0);
  return 0;
}
