#include <bits/stdc++.h>
using namespace std;
int main() {
  long a, m[101][101] = {}, m1[101] = {}, m2[101];
  cin >> a;
  for (int i = 0; i < a - 1; i++) {
    long x, y, z;
    cin >> x >> y >> z;
    m[x][y] = z;
    m[y][x] = z;
  }
  m1[0] = 0;
  m2[0] = 0;
  for (int i = 1; i < a; i++) m2[i] = -1;
  long dau = 0;
  long cuoi = 0;
  long maxgt = 0;
  while (dau <= cuoi) {
    for (int i = 0; i < a; i++)
      if ((m[m1[dau]][i] > 0) && (m2[i] == -1)) {
        cuoi++;
        m1[cuoi] = i;
        m2[i] = m2[m1[dau]] + m[m1[dau]][i];
        if (maxgt < m2[i]) maxgt = m2[i];
      }
    dau++;
  }
  cout << maxgt;
}
