#include <bits/stdc++.h>
const int INF = 1e9 + 7;
using namespace std;
int ans;
map<pair<int, int>, int> mp;
int vis[1001];
void dfs(int node, vector<int> v[], int sum) {
  vis[node] = 1;
  ans = max(ans, sum);
  for (auto ch : v[node]) {
    if (vis[ch] == -1) dfs(ch, v, sum + mp[{ch, node}]);
  }
}
signed main() {
  int n;
  cin >> n;
  ans = 0;
  mp.clear();
  vector<int> v[n];
  memset(vis, -1, sizeof(vis));
  for (int i = 0; i < n - 1; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    v[x].push_back(y);
    v[y].push_back(x);
    mp[{x, y}] = w;
    mp[{y, x}] = w;
  }
  dfs(0, v, 0);
  cout << ans << "\n";
  return 0;
}
