#include <bits/stdc++.h>
using namespace std;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
const int M = 1e9 + 7;
const int N = 2e5 + 5;
const char dc[4] = {'D', 'R', 'U', 'L'};
int n, m, mx;
vector<vector<pair<int, int>>> adj(105);
int vis[105];
void dfs(int i, int cost) {
  vis[i] = 1;
  for (auto x : adj[i]) {
    if (!vis[x.first]) {
      dfs(x.first, cost + x.second);
    }
  }
  if (mx < cost) mx = cost;
}
void solve() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    adj[u].push_back(make_pair(v, c));
    adj[v].push_back(make_pair(u, c));
  }
  dfs(0, 0);
  cout << mx << endl;
}
int main() {
  fast();
  solve();
  return 0;
}
