#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e6 + 10;
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input() {}
int n, m;
int d[SIZE];
vector<pair<int, int>> Adj[SIZE];
int vis[SIZE];
int mn = 0, ans = 0;
int path = 0;
int cost[SIZE];
void dfs(int v, int ac) {
  vis[v] = 1;
  for (auto u : Adj[v]) {
    if (vis[u.first] != 1) {
      dfs(u.first, ac + u.second);
    }
  }
  ans = max(ac, ans);
}
int main() {
  fastio();
  input();
  d[0] = -1;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    long long int u, v, c;
    cin >> u >> v >> c;
    Adj[u].push_back(make_pair(v, c));
    Adj[v].push_back(make_pair(u, c));
  }
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}
