#include #include #include #include #include #include using namespace std; typedef long long int ll; #define repi(i,a,b) for(ll i=a;i=0;i--) // ll count(ll start, vector> edges, ll* visited){ // // printf("%lld : ", start); // // rep(i, (ll)edges.size()) printf("%lld ", visited[i]); // // cout << '\n' << endl; // // visited[start] = 1; // bool stop = true; // ll cnt = 0; // for(auto it = edges[start].begin(); it != edges[start].end(); ++it){ // if(!visited[*it]){ // cnt += count(*it, edges, visited); // if(!stop) cnt++; // stop = false; // } // } // if(stop) cout << start << endl; // return cnt; // } int main(){ ll N; cin >> N; vector > edges(N); rep(i, N-1){ ll a, b; cin >> a >> b; edges[a-1].push_back(b-1); edges[b-1].push_back(a-1); } bool visited[N]; rep(i, N) visited[i] = 0; ll ans = 0; ll start = 0; while(edges[start].size() != 1) start++; vector search(1, start); rep(i, N){ visited[search[i]] = true; ll cnt = 0; for(auto it = edges[search[i]].begin(); it != edges[search[i]].end(); ++it){ if(!visited[*it]){ search.push_back(*it); cnt++; } } if(cnt) ans += cnt - 1; } cout << ans << endl; return 0; }