#include <bits/stdc++.h>
using namespace std;
long long int ans = 0;
bool vis[200] = {false};
vector<long long int> v[200];
long long int sum = 0;
void dfs(long long int x, long long int cost[][1000], long long int sum) {
  vis[x] = true;
  for (long long int i = 0; i < v[x].size(); i++) {
    if (vis[v[x][i]] == false) {
      dfs(v[x][i], cost, sum + cost[x][v[x][i]]);
    }
  }
  ans = max(ans, sum);
}
int32_t main() {
  long long int n;
  cin >> n;
  long long int cost[100][1000] = {0};
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y, z;
    cin >> x >> y >> z;
    v[x].push_back(y);
    v[y].push_back(x);
    cost[x][y] = z;
    cost[y][x] = z;
  }
  for (long long int i = 0; i < n; i++) {
    if (vis[i] == false) {
      dfs(i, cost, 0);
    }
  }
  cout << ans << endl;
}
