#include <bits/stdc++.h>
using namespace std;
const long long int Mod = 998244353;
const long long int mod = 1e9 + 7;
long long int Pow(long long int a, long long int b) {
  a = a % mod;
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return (res % mod);
}
long long int modInverse(long long int a, long long int m) {
  return Pow(a, m - 2);
}
const int N = 305;
vector<int> adj[N];
int dp[N][N];
bool vis[N];
int dfs(int s) {
  vis[s] = true;
  int mx = 0;
  for (auto u : adj[s]) {
    if (!vis[u]) {
      int tot = dp[s][u] + dfs(u);
      mx = max(tot, mx);
    }
  }
  return mx;
}
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    adj[a].push_back(b);
    adj[b].push_back(a);
    dp[a][b] = dp[b][a] = c;
  }
  cout << dfs(0);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
