#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 101;
vector<vector<pair<int, int> > > adjList(MAX_N);
vector<int> distanceVector(MAX_N);
void bfs(int source) {
  queue<pair<int, int> > q;
  q.push(make_pair(source, -1));
  pair<int, int> curr;
  while (!q.empty()) {
    curr = q.front();
    q.pop();
    for (int i = 0; i < adjList[curr.first].size(); i++) {
      if (curr.second == adjList[curr.first][i].first) continue;
      distanceVector[adjList[curr.first][i].first] =
          max(distanceVector[adjList[curr.first][i].first],
              distanceVector[curr.first] + adjList[curr.first][i].second);
      q.push(make_pair(adjList[curr.first][i].first, curr.first));
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int i, n, f1, f2, d;
  scanf("%d", &n);
  for (i = 0; i < n - 1; i++) {
    distanceVector[i] = 0;
    scanf("%d %d %d", &f1, &f2, &d);
    adjList[f1].push_back(make_pair(f2, d));
    adjList[f2].push_back(make_pair(f1, d));
  }
  bfs(0);
  int ans = 0;
  for (i = 0; i < n; i++) {
    ans = max(ans, distanceVector[i]);
  }
  printf("%d", ans);
  return 0;
}
