#include <bits/stdc++.h>
using namespace std;
int mx, i, j, n, m, k, t, x, y, c, d, s;
vector<pair<int, int> > v[1000];
void dfs(int u, int w) {
  vector<pair<int, int> >::iterator p;
  pair<int, int> q;
  for (p = v[u].begin(); p != v[u].end(); ++p) {
    q = *p;
    if (q.first != w) {
      s += q.second;
      dfs(q.first, u);
      s -= q.second;
    }
  }
  mx = max(s, mx);
}
int main() {
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> x >> y >> c;
    v[x].push_back({y, c});
    v[y].push_back({x, c});
  }
  dfs(0, -1);
  cout << mx;
}
