#include <bits/stdc++.h>
using namespace std;
bool kt[101] = {0};
int t = 0, res = 0;
int a[101][101];
int n, x, y, c;
void try1(int i) {
  kt[i] = 1;
  for (int j = 0; j < n; j++)
    if (!kt[j] && a[i][j] != 0) {
      t += a[i][j];
      kt[j] = 1;
      if (t > res) res = t;
      try1(j);
      t -= a[i][j];
      kt[j] = 0;
    }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y >> c;
    a[x][y] = c;
    a[y][x] = c;
  }
  int k, x;
  try1(0);
  cout << res;
  return 0;
}
