#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
struct Edge {
  int to;
  int next;
  int w;
} e[maxn << 1];
int head[maxn];
int tot;
int mxcost;
void addedge(int u, int v, int w) {
  e[tot].to = v;
  e[tot].w = w;
  e[tot].next = head[u];
  head[u] = tot++;
}
void dfs(int x, int fa, int cost) {
  mxcost = max(mxcost, cost);
  for (int i = head[x]; ~i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs(v, x, cost + e[i].w);
  }
}
int main() {
  memset(head, -1, sizeof head);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    u++;
    v++;
    addedge(u, v, w);
    addedge(v, u, w);
  }
  dfs(1, 0, 0);
  printf("%d\n", mxcost);
  return 0;
}
