#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> adj[100];
bool visited[100];
int res = 0;
void dfs(int src, int s) {
  visited[src] = true;
  if (src != 0 && adj[src].size() == 1) res = max(res, s);
  int i;
  for (i = 0; i < adj[src].size(); i++) {
    if (visited[adj[src][i].first] == false) {
      dfs(adj[src][i].first, (s + (adj[src][i].second)));
    }
  }
}
int main() {
  int n;
  cin >> n;
  int i;
  int u, v, c;
  for (i = 0; i < n - 1; i++) {
    cin >> u >> v >> c;
    adj[u].push_back({v, c});
    adj[v].push_back({u, c});
    visited[i] = false;
  }
  visited[n - 1] = false;
  dfs(0, 0);
  cout << res << endl;
}
