#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adjl(101);
int gans = 0;
map<pair<int, int>, int> mp;
void dfs(int n, int p, int ans) {
  gans = max(ans, gans);
  for (int i = 0; i < adjl[n].size(); i++) {
    int ch = adjl[n][i];
    if (ch != p) {
      dfs(ch, n, ans + mp[make_pair(n, ch)]);
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (n - 1); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    adjl[a].push_back(b);
    adjl[b].push_back(a);
    mp[make_pair(a, b)] = c;
    mp[make_pair(b, a)] = c;
  }
  dfs(0, -1, 0);
  cout << gans << endl;
}
