#include <bits/stdc++.h>
using namespace std;
unordered_map<int, list<pair<int, int>>> l;
int vis[101] = {0};
int a, b, c;
int ans = 0;
int dfs(int src) {
  vis[src] = 1;
  int ans = 0, to, cost = 0;
  for (auto p : l[src]) {
    int to = p.first, cost = p.second;
    if (!vis[to]) {
      ans = max(ans, cost + dfs(to));
    }
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a >> b >> c;
    l[a].push_back(make_pair(b, c));
    l[b].push_back(make_pair(a, c));
  }
  cout << dfs(0) << endl;
}
