#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 1;
const int MOD = 1e9 + 7;
int N;
long long sum;
long long mx;
vector<vector<pair<int, int> > > G(101);
bool used[101];
void DFS(int v, int sm) {
  if (used[v]) return;
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    int to = G[v][i].second;
    if (!used[to]) {
      sum += G[v][i].first;
      DFS(to, G[v][i].first);
    }
  }
  mx = max(mx, sum);
  sum -= sm;
}
int main() {
  cin >> N;
  for (int i = 1; i < N; i++) {
    int v, u, w;
    cin >> v >> u >> w;
    G[v].push_back({w, u});
    G[u].push_back({w, v});
  }
  for (int i = 0; i < N; i++) {
    sort(G[i].begin(), G[i].end());
    reverse(G[i].begin(), G[i].end());
  }
  for (int i = 0; i < G[0].size(); i++) {
    memset(used, false, sizeof(used));
    sum = 0;
    int to = G[0][i].second;
    used[0] = true;
    sum += G[0][i].first;
    DFS(to, 0);
    mx = max(mx, sum);
    sum = 0;
  }
  cout << mx;
  return 0;
}
