#include <bits/stdc++.h>
using namespace std;
const int N = 110, M = N * 2;
int h[N], ne[M], e[M], idx, w[M];
int dep[N], dis[N], n, max_dep = -1, max_dis = -1;
void add(int a, int b, int c) {
  e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx++;
  e[idx] = a, w[idx] = c, ne[idx] = h[b], h[b] = idx++;
}
void bfs(int x) {
  queue<int> q;
  q.push(x);
  dep[x] = 1;
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int i = h[u]; ~i; i = ne[i]) {
      if (dep[e[i]] == 0) {
        dep[e[i]] = dep[u] + 1;
        dis[e[i]] = dis[u] + w[i];
        max_dis = max(max_dis, dis[e[i]]);
        q.push(e[i]);
      }
    }
  }
}
int main() {
  cin >> n;
  memset(h, -1, sizeof h);
  for (int i = 1; i < n; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    a++, b++;
    add(a, b, c);
  }
  bfs(1);
  printf("%d\n", max_dis);
  return 0;
}
