#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> v[101];
int d[101];
void dfs(int nod, int prt, int cost) {
  d[nod] = d[prt] + cost;
  for (auto fiu : v[nod])
    if (fiu.first != prt) {
      dfs(fiu.first, nod, fiu.second);
    }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    v[a].push_back({b, c});
    v[b].push_back({a, c});
  }
  dfs(0, -1, 0);
  cout << *max_element(d, d + n + 1);
}
