typedef long long ll; #include using namespace std; template void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } int main() { ll n; std::cin >> n; // vector node[100010]; ll node_count[100010]; Fill(node_count,0); for (int i = 0; i < n-1; i++) { // 0-indexed ll tmp_a,tmp_b; std::cin >> tmp_a>>tmp_b; tmp_a--; tmp_b--; node_count[tmp_a]++; node_count[tmp_b]++; } ll result = 0; for (int i = 0; i < n; i++) { result += max(node_count[i] -2,(ll)0); } std::cout << result << std::endl; }