#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define int long long typedef vector VI; typedef pair pii; #define fore(i,a) for(auto &i:a) #define REP(i,n) for(int i=0;i > dp; //vector > > vvvi; //dp=vector >(N, vector(M,0)); //vector > v; //v.push_back(make_pair(x,y)); //priority_queue, greater > q2; int N; VI G[100010]; int dp[100010][2]; int dfs(int cu, int pa,int co) { if (dp[cu][co] != -1)return dp[cu][co]; if (co == 0)dp[cu][0] = 0; else dp[cu][1] = 1; REP(i,G[cu].size()){ int ch = G[cu][i]; if (ch == pa) continue; if (co == 0) { dp[cu][0] += max(dfs(ch, cu, 0), dfs(ch, cu, 1)); } else { dp[cu][1] += max(dfs(ch, cu, 0), dfs(ch, cu, 1) - 1); } } return dp[cu][co]; } signed main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> N; REP(i, N)dp[i][0] = dp[i][1] = -1; REP(i, N - 1) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } cout << max(dfs(0,-1,0) ,dfs(0,-1,1)) << endl; //REP(i, N)cout << dp[i][0] << dp[i][1] << endl; return 0; }