#include using namespace std; constexpr int nax = 3e5; int n, res = 0; vector< int > gr[nax + 1]; void dfs(const int v, const int oj) { int st = 0; for (int s : gr[v]) if (s != oj) { ++st; dfs(s, v); } res += max(0, st - 1); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i = 0; i < n - 1; ++i) { int p, q; cin >> p >> q; gr[p].push_back(q); gr[q].push_back(p); } for (int i = 1; i <= n; ++i) if (gr[i].size() == 1) { dfs(i, i); break; } cout << res << '\n'; }