#include <bits/stdc++.h>
using namespace std;
vector<long long> primes;
struct node {
  long long des;
  long long w;
};
void sieve(long long n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long p = 2; p <= n; p++)
    if (prime[p]) primes.push_back(p);
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
bool checkInSet(set<long long>& s, long long item) {
  auto it = s.find(item);
  if (it == s.end()) return false;
  return true;
}
long long fastPower(long long x, long long y) {
  long long temp;
  if (y == 0) return 1;
  temp = fastPower(x, y / 2);
  if (y % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
long long inverseModPower(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long modInverse(long long n, long long p) {
  return inverseModPower(n, p - 2, p);
}
long long nCr(long long n, long long r, long long p) {
  if (n < r) return 0;
  if (r == 0) return 1;
  long long fac[n + 1];
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = (fac[i - 1] * i) % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
long long dfs(vector<vector<node>>& v, long long index, set<long long> s) {
  long long ans = 0;
  long long size = v[index].size();
  for (long long i = 0; i < size; i++) {
    if (!checkInSet(s, v[index][i].des)) {
      s.insert(v[index][i].des);
      ans = max(ans, dfs(v, v[index][i].des, s) + v[index][i].w);
      s.erase(v[index][i].des);
    }
  }
  return ans;
}
void solve() {
  long long n;
  cin >> n;
  vector<vector<node>> v(105);
  while (n--) {
    long long a, b, c;
    cin >> a >> b >> c;
    struct node ne;
    ne.des = b;
    ne.w = c;
    v[a].push_back(ne);
    ne.des = a;
    v[b].push_back(ne);
  }
  set<long long> s;
  s.insert(0);
  long long ans = dfs(v, 0, s);
  cout << ans;
}
int main() {
  long long t = 1;
  while (t--) solve();
}
