#include #include #include #include #include using namespace std; vector> Graph; vector checked; vector> vec; int dfs(int i,int parent){ checked[i]=true; for(int to:Graph[i]){ if(!checked[to]){ int p=dfs(to,i); vec[i].push(p); } } int res=1; if(vec[i].size()<=2){ while(!vec[i].empty()){ res+=vec[i].top(); vec[i].pop(); } }else{ for(int j=0;j<2;j++){ res+=vec[i].top(); vec[i].pop(); } if(parent!=-1){ while(!vec[i].empty()){ vec[parent].push(vec[i].top()); vec[i].pop(); } } } return res; } int main(){ int N; cin>>N; Graph.resize(N); checked.resize(N,false); vec.resize(N); for(int i=0; i>x>>y; Graph[x-1].push_back(y-1); Graph[y-1].push_back(x-1); } int ans=dfs(0,-1); cout<