#include <bits/stdc++.h>
using namespace std;
const int INF = 10048;
vector<pair<int, int> > v[148];
int n;
int sum = 0, ans = 0;
void dfs(int cur, int father) {
  if (v[cur].size() == 1 && cur != 0) {
    ans = max(ans, sum);
    return;
  }
  int i;
  for (i = 0; i < v[cur].size(); i++)
    if (v[cur][i].first != father) {
      sum += v[cur][i].second;
      dfs(v[cur][i].first, cur);
      sum -= v[cur][i].second;
    }
}
int main() {
  int i, first, second, c;
  cin >> n;
  for (i = 1; i <= n - 1; i++) {
    cin >> first >> second >> c;
    v[first].push_back(make_pair(second, c));
    v[second].push_back(make_pair(first, c));
  }
  dfs(0, -1);
  cout << ans << endl;
  return 0;
}
