#include <bits/stdc++.h>
using namespace std;
vector<int> arr[200];
vector<bool> vis(200, 0);
int dis[101][101];
int cost = -1;
int dfs(int st, int tot) {
  vis[st] = 1;
  for (auto x : arr[st]) {
    if (!vis[x]) {
      dfs(x, tot + dis[st][x]);
    }
  }
  return cost = max(cost, tot);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, u, v, c;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v >> c;
    arr[u].push_back(v);
    arr[v].push_back(u);
    dis[u][v] = c;
    dis[v][u] = c;
  }
  int ans = dfs(0, 0);
  cout << ans;
}
