#include <bits/stdc++.h>
using namespace std;
int n;
int map[300][300];
struct node {
  int to, from, next;
  int value;
} edg[300 << 2];
int vis[300 << 2], cnt = 0, head[300 << 2];
void add(int u, int v, int w) {
  edg[cnt].value = w;
  edg[cnt].from = u;
  edg[cnt].to = v;
  edg[cnt].next = head[u];
  head[u] = cnt++;
}
int maxn = 0;
void dfs(int to, int ans) {
  if (ans > maxn) {
    maxn = ans;
  }
  for (int i = head[to]; i != -1; i = edg[i].next) {
    int v = edg[i].to;
    if (!vis[v]) {
      vis[v] = 1;
      dfs(v, ans + edg[i].value);
      vis[v] = 0;
    }
  }
}
int main() {
  int a, b, c;
  scanf("%d", &n);
  memset(head, -1, sizeof(head));
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d%d", &a, &b, &c);
    add(a, b, c);
    add(b, a, c);
  }
  vis[0] = 1;
  dfs(0, 0);
  printf("%d", maxn);
}
