#include <bits/stdc++.h>
using namespace std;
const int N = 100;
vector<pair<int, int> > adj[N];
int n, u, v, c;
int cost = 0;
void dfs(int u, int p, int curr) {
  for (pair<int, int> i : adj[u]) {
    if (i.first != p) {
      dfs(i.first, u, curr + i.second);
    }
  }
  if (adj[u].size() == 1) cost = max(cost, curr);
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v >> c;
    adj[u].emplace_back(v, c);
    adj[v].emplace_back(u, c);
  }
  dfs(0, -1, 0);
  cout << cost << '\n';
  return 0;
}
