#include <bits/stdc++.h>
using namespace std;
int answer;
const int mxN = 1e2 + 10;
vector<vector<pair<int, int> > > edges(mxN);
void dfs(int node, int par, int cost) {
  answer = max(answer, cost);
  for (auto child : edges[node]) {
    if (par != child.first) {
      dfs(child.first, node, child.second + cost);
    }
  }
  return;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    edges[u].push_back(make_pair(v, c));
    edges[v].push_back(make_pair(u, c));
  }
  answer = INT_MIN;
  dfs(0, -1, 0);
  cout << answer << "\n";
  return 0;
}
