#include <bits/stdc++.h>
using namespace std;
struct edge {
  int np, next, va;
} e[101 << 1];
int e_ct = 1;
int head[101];
inline void adde(int u, int v, int va) {
  e[++e_ct] = (edge){v, head[u], va};
  head[u] = e_ct;
  e[++e_ct] = (edge){u, head[v], va};
  head[v] = e_ct;
}
int le[101];
int fa[101];
inline void dfs(int x) {
  for (int ne = head[x]; ne; ne = e[ne].next) {
    int cur = e[ne].np;
    if (cur == fa[x]) continue;
    fa[cur] = x;
    dfs(cur);
    le[x] = max(le[x], le[cur] + e[ne].va);
  }
}
int n;
int u, v, c;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; ++i) {
    scanf("%d%d%d", &u, &v, &c);
    adde(u, v, c);
  }
  dfs(0);
  printf("%d\n", le[0]);
  return 0;
}
