#include <bits/stdc++.h>
using namespace std;
int graph[100][100];
bool used[100];
int maxCost = 0;
int friends = 0;
void DFS(int currV, int currC) {
  if (currC > maxCost) {
    maxCost = currC;
  }
  used[currV] = true;
  int u = 0;
  for (int i = 0; i < friends; i++) {
    if (used[i]) u++;
  }
  if (u == friends) {
    currC = 0;
  }
  for (int i = 0; i < friends; i++) {
    if (!used[i] && graph[currV][i] != -1) {
      DFS(i, currC + graph[currV][i]);
    }
  }
}
int main() {
  cin >> friends;
  int u, v, c;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      graph[i][j] = -1;
    }
  }
  for (int i = 0; i < 100; i++) {
    used[i] = false;
  }
  for (int i = 0; i < friends - 1; i++) {
    cin >> u >> v >> c;
    graph[u][v] = c;
    graph[v][u] = c;
  }
  DFS(0, 0);
  cout << maxCost << endl;
  return 0;
}
