#include <bits/stdc++.h>
using namespace std;
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int XX[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int YY[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int N = 105;
int ans = 0;
vector<pair<int, int>> adj[N];
bool vist[N];
void dfs(int node, int cost) {
  vist[node] = 1;
  ans = max(ans, cost);
  for (auto child : adj[node])
    if (!vist[child.first]) dfs(child.first, cost + child.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    adj[u].push_back({v, c});
    adj[v].push_back({u, c});
  }
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}
