#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > adj[101];
int label[101];
int vis[101];
void dfs(int s) {
  vis[s] = 1;
  for (auto it : adj[s]) {
    if (!vis[it.first]) {
      label[it.first] += label[s] + it.second;
      dfs(it.first);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a, b, w;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b >> w;
    adj[a].push_back({b, w});
    adj[b].push_back({a, w});
  }
  dfs(0);
  sort(label, label + 101);
  cout << label[100] << endl;
  return 0;
}
