#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> g[105];
int ans = 0, now = 0;
void dfs(int s, int f) {
  ans = max(ans, now);
  for (auto x : g[s]) {
    if (x.first == f) continue;
    now += x.second;
    dfs(x.first, s);
    now -= x.second;
  }
  return;
}
int main() {
  int n, a, b, w, i;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d %d %d", &a, &b, &w);
    g[a].push_back({b, w});
    g[b].push_back({a, w});
  }
  dfs(0, -1);
  printf("%d", ans);
  return 0;
}
