#include #define rep(i, n) for(int i = 0; i < (int)(n); i++) using namespace std; using Graph = vector>; Graph G; int ans = 0; void dfs(int v, int p){ if(G[v].size() >= 3) ans += (G[v].size() - 2); for(auto nv: G[v]){ if(nv == p) continue; dfs(nv, v); } } int main(){ int n; cin >> n; G.assign(n+1, vector()); rep(i, n-1){ int v, u; cin >> v >> u; G[v].push_back(u); G[u].push_back(v); } dfs(1, 0); cout << ans << endl; return 0; }