#include "bits/stdc++.h" #define ALL(obj) (obj).begin(),(obj).end() #define RALL(obj) (obj).rbegin(),(obj).rend() #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define REPR(i, n) for(int i = (int)(n); i >= 0; i--) #define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++) using namespace std; typedef long long ll; const int MOD = 1e9 + 7; const int INF = MOD - 1; const ll LLINF = 4e18; vector> dp,tree; int sol(int v, int f ,int p = -1) { if (dp[v][f] != -1) return dp[v][f]; dp[v][f] = f; for (int u : tree[v]) { if (u == p) continue; dp[v][f] += max(sol(u, 0, v), sol(u, 1, v) - f); } return dp[v][f]; } int main() { int n; cin >> n; tree.resize(n); dp.resize(n, vector(2,-1)); REP(i, n - 1) { int u, v; cin >> u >> v; u--; v--; tree[u].push_back(v); tree[v].push_back(u); } cout << max(sol(0, 0), sol(0, 1)) << endl; getchar(); getchar(); }