#include "bits/stdc++.h" #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i> N; std::vectora(N - 1), b(N - 1); rep(i, N - 1) in >> a[i] >> b[i]; std::vectorcnt(N + 1); rep(i, N - 1) { ++cnt[a[i]]; ++cnt[b[i]]; } LL ans = 0; for (LL i = 1; i <= N; ++i) { if (cnt[i] > 2) ans += cnt[i] - 2; } out << ans << std::endl; }