#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define INF 10e17 #define rep(i,n) for(long long i=0; i()) #define debug(x) std::cerr << (x) << std::endl; #define roll(x) for (auto&& itr : x) { debug(itr); } template inline void chmax(T &ans, T t) { if (t > ans) ans = t;} template inline void chmin(T &ans, T t) { if (t < ans) ans = t;} int total; void dfs(vector> const& g, int from, int now, int invRank) { int trank = invRank + 1; total += max(g[now].size() - 2, 0); for (auto&& itr : g[now]) { if (itr != from) { dfs(g, now, itr, trank); } } } int main() { int n; cin >> n; vector> g(n); rep(i, n-1) { int a, b; cin >> a >> b; a--, b--; g[a].push_back(b); g[b].push_back(a); } dfs(g, -1, 0, 0); cout << total << endl; }