#include <bits/stdc++.h>
using namespace std;
const int SIZE = 3e5 + 5;
const long long INF = 1e14 + 5;
const long long MOD = 1e9 + 7;
struct abc {
  int t;
  int p;
};
bool operator<(abc a, abc b) {
  int r1 = min(a.t, a.p) - min(a.t * 2, a.p);
  int r2 = min(b.t, b.p) - min(b.t * 2, b.p);
  return r1 < r2;
}
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
bool inRange(int n, int m, int n0, int m0) {
  return n0 > -1 && m0 > -1 && m0 < m && n0 < n;
}
bool cmp1(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
bool cmp2(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int s[105];
int main() {
  int n, u, v, c;
  scanf("%d", &n);
  vector<vector<pair<int, int> > > G(n + 1);
  vector<char> used(n + 1);
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d%d%d", &u, &v, &c);
    G[u].push_back(make_pair(v, c));
    G[v].push_back(make_pair(u, c));
  }
  queue<int> q;
  q.push(0);
  int ans = 0;
  while (!q.empty()) {
    int top = q.front();
    q.pop();
    if (used[top]) continue;
    used[top] = true;
    for (int i = 0; i < G[top].size(); ++i) {
      pair<int, int> to = G[top][i];
      if (used[to.first]) continue;
      s[to.first] = max(s[to.first], s[top] + to.second);
      ans = max(ans, s[to.first]);
      q.push(to.first);
    }
  }
  printf("%d", ans);
  return 0;
}
