#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
int u;
int v;
int w;
int mx;
vector<pair<int, int> > adj[N];
bool visited[200000];
void solve(int u, int cost) {
  mx = max(mx, cost);
  visited[u] = true;
  for (int i = 0; i < adj[u].size(); ++i) {
    if (visited[adj[u][i].first] != true) {
      solve(adj[u][i].first, cost + adj[u][i].second);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d %d %d", &u, &v, &w);
    adj[u].push_back(make_pair(v, w));
    adj[v].push_back(make_pair(u, w));
  }
  solve(0, 0);
  printf("%d\n", mx);
  return 0;
}
