#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > adj[100];
bool visited[100];
void dfs(int strt, int sum, int& max_sum, bool root) {
  visited[strt] = true;
  if (adj[strt].size() == 1 && root == false) {
    max_sum = max(max_sum, sum);
    return;
  }
  for (int i = 0; i < adj[strt].size(); i++)
    if (visited[adj[strt][i].first] == false)
      dfs(adj[strt][i].first, sum + adj[strt][i].second, max_sum, false);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) visited[i] = false;
  for (int i = 0; i < n - 1; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    adj[u].push_back(make_pair(v, c));
    adj[v].push_back(make_pair(u, c));
  }
  int max_sum = INT_MIN;
  dfs(0, 0, max_sum, true);
  cout << max_sum;
}
