#include #include template struct Edge { int from, to; T cost; Edge(int from = -1, int to = -1, T cost = 1) : from(from), to(to), cost(cost){}; bool operator<(const Edge& e) const { return this->cost < e.cost; } bool operator>(const Edge& e) const { return this->cost > e.cost; } }; template class Graph { public: explicit Graph(int N = 0) : size(N) { path.resize(size); } void span(int u, int v, T cost = 1) { path[u].push_back(Edge(u, v, cost)); } std::vector> operator[](int v) const { return path[v]; } int size; std::vector>> path; }; int main() { int N; std::cin >> N; Graph<> tree(N); for (int i = 0; i < N - 1; ++i) { int u, v; std::cin >> u >> v; --u, --v; tree.span(u, v); tree.span(v, u); } int ans = 0; for (int v = 0; v < N; ++v) { ans += std::max(0, (int)tree[v].size() - 2); } std::cout << ans << std::endl; return 0; }