#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void print(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
const int N = 2e6 + 5;
const int maxn = 1e2 + 5;
vector<pair<int, int>> e[maxn];
long long dp[maxn];
void dfs(int x, int fa) {
  for (int i = 0; i < e[x].size(); i++) {
    int y = e[x][i].first, w = e[x][i].second;
    if (y == fa) continue;
    dp[y] = max(dp[x] + w, dp[y]);
    dfs(y, x);
  }
}
int main() {
  int n = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read(), w = read();
    u++, v++;
    e[u].push_back({v, w});
    e[v].push_back({u, w});
  }
  dfs(1, 0);
  long long Max = 0;
  for (int i = 1; i <= n; i++) Max = max(Max, dp[i]);
  printf("%lld\n", Max);
  return 0;
}
