#include <bits/stdc++.h>
using namespace std;
int n;
int ans = 0;
int g[105][105];
int tmp = 0;
bool vsd[105];
void DFS(int a) {
  vsd[a] = true;
  bool br = false;
  for (int i = 1; i <= n; i++) {
    if (!g[a][i] || vsd[i]) continue;
    br = true;
    tmp += g[a][i];
    DFS(i);
    tmp -= g[a][i];
  }
  if (!br) ans = max(ans, tmp);
  vsd[a] = false;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a][b] = g[b][a] = c;
  }
  DFS(0);
  cout << ans;
  return 0;
}
