#include <bits/stdc++.h>
using namespace std;
vector<int> visited(101);
map<pair<int, int>, int> edge;
vector<int> g[101];
int ans = 0;
void dfs(int u, int cost) {
  visited[u] = 1;
  if ((int)g[u].size() == 1) ans = max(ans, cost);
  for (auto v : g[u]) {
    if (!visited[v]) {
      dfs(v, cost + edge[{u, v}]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    g[u].push_back(v);
    g[v].push_back(u);
    edge[{u, v}] = c;
    edge[{v, u}] = c;
  }
  dfs(0, 0);
  cout << ans;
}
