#include // #include using namespace std; // using namespace atcoder; typedef int64_t lint; #define rep(i, n) for(int i=0; i; using vvi = vector>; template inline void vin(vector& v) { rep(i, v.size()) cin >> v.at(i); } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template inline void drop(T x) { cout << x << endl; exit(0); } template void vout(vector v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; } constexpr lint LINF = LLONG_MAX/2; using pint = pair; using vp = vector; vector> G; void make_graph(int N) { G.resize(N); int x, y; rep(i, N-1) { cin >> x >> y; x--, y--; G[x].push_back(y); G[y].push_back(x); } } pint rec(int x, int from) { vi v; lint y, z, a=0; for (auto t : G[x]) { if (t == from) continue; tie(y, z) = rec(t, x); a += y+z; if (y%2 == 0) y--; v.pb(y); } if (v.size() == 0) return {1, 0}; sort(all(v), greater()); if (v.size() == 1) { if (a-v[0]) return {v[0]+2, a-v[0]-1}; else return {v[0]+1, a-v[0]}; } else return {v[0]+v[1]+1, a-v[0]-v[1]}; } int main() { lint N; cin >> N; make_graph(N); lint a=0, b=0, c=0, x, y, z; tie(x, y) = rec(0, -1); std::cout << x << '\n'; }