#include #define rep(i, n) for (int i=0; i<(int)(n); i++) #define all(v) v.begin(), v.end() #define PRINT(v) for (auto x : (v)) cout <>; using mat = vector>; const ll MOD = 1000000007; const ll INF = 10000000000000000; vector x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1}; vector y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1}; template inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;} template inline bool chmax(T& a, T b){if (a inline T powerM(T a,T b){if (b==0) return 1; T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; } template inline T power(T a,T b,T m){ if (b==0) return 1; T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; } template inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);} template inline T lcm(T a, T b){return a / gcd(a,b) * b;} // ax+by=gcd(a,b)を解く template inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;} void hey(){ cout <<"hey" < struct edge { int to; T cost;}; int N; Graph G; vector dp; vector del; void dfs(int v, int p){ // 自分の子のうち、一つでも削除されていないものがあれば自分を削除する // 自分の子が一つも残っていないかそもそも存在しないなら自分は削除しない int res = 0; for (int nv : G[v]){ if (nv == p) continue; dfs(nv, v); if (!del[nv]) del[v] = true; res += dp[nv]; } // 自分の子のうち残っているものがk個だとすると、 // 自分を削除すればそれらが独立するけど足し算してたから関係ないね dp[v] = res + (!del[v]); } int main() { cin >>N; G.assign(N, vector()); rep(i, N-1){ int x,y; cin >>x >>y; x--; y--; G[x].push_back(y); G[y].push_back(x); } dp.assign(N, 0); // dp[i] := 連結成分の個数の最大値 del.assign(N, false); dfs(0, -1); int res = dp[0]; cout <