#include #include struct Node { std::list neighbourList; bool marked; Node(): marked(false) { } }; int main() { unsigned n, i, a, b, cuts, markedNeighbours; scanf("%u", &n); Node nodes[n + 1]; for(i = 0; i < n - 1; ++i) { scanf("%u %u", &a, &b); nodes[a].neighbourList.push_back(b); nodes[b].neighbourList.push_back(a); } cuts = 0; for(i = 1; i <= n; ++i) { if(nodes[i].neighbourList.size() > 2) { cuts += nodes[i].neighbourList.size() - 2; } } printf("%u\n", cuts); return 0; }