#include <bits/stdc++.h>
using namespace std;
const int N = 111;
int n, k, ans, a, b, c;
bool Z[N];
vector<pair<int, int> > v[N];
int dfs(int x, bool *vis) {
  int ret = 0;
  for (auto u : v[x]) {
    if (!vis[u.first]) {
      vis[u.first] = 1;
      ret = max(ret, dfs(u.first, vis) + u.second);
      vis[u.first] = 0;
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b >> c;
    v[a].push_back({b, c});
    v[b].push_back({a, c});
  }
  Z[0] = 1;
  cout << dfs(0, Z) << endl;
}
