#include <bits/stdc++.h>
using namespace std;
const long long int MAX = 2e5 + 14;
vector<long long int> Tree[MAX];
long long int W[101][101];
vector<bool> seen(MAX);
long long int res = 0;
void dfs(long long int node, long long int su) {
  for (auto adj : Tree[node]) {
    if (seen[adj] == false) {
      seen[adj] = true;
      su += W[node][adj];
      res = max(res, su);
      dfs(adj, su);
      su -= W[node][adj];
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long int n;
  cin >> n;
  for (long long int i = 1; i < n; ++i) {
    long long int u, v, c;
    cin >> u >> v >> c;
    W[u][v] = c;
    W[v][u] = c;
    Tree[u].emplace_back(v);
    Tree[v].emplace_back(u);
  };
  seen[0] = true;
  long long int su = 0;
  dfs(0, su);
  cout << res << "\n";
}
