#include <bits/stdc++.h>
using namespace std;
const int N = 105;
vector<pair<int, int> > graph[N];
bool visited[N];
int mx, val;
void dfs(int st, int cur) {
  visited[st] = true;
  for (int i = 0; i < graph[st].size(); i++) {
    pair<int, int> n = graph[st][i];
    int node = n.first;
    int cost = n.second;
    if (graph[node].size() == 1) {
      mx = max(mx, cur + cost);
    }
    if (!visited[node]) {
      dfs(node, cur + cost);
    }
  }
}
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= (n - 1); i++) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    graph[u].push_back({v, c});
    graph[v].push_back({u, c});
  }
  dfs(0, 0);
  printf("%d\n", mx);
  return 0;
}
